Skip to content
  • Categories
  • Recent
  • Tags
  • Popular
  • World
  • Users
  • Groups
Skins
  • Light
  • Cerulean
  • Cosmo
  • Flatly
  • Journal
  • Litera
  • Lumen
  • Lux
  • Materia
  • Minty
  • Morph
  • Pulse
  • Sandstone
  • Simplex
  • Sketchy
  • Spacelab
  • United
  • Yeti
  • Zephyr
  • Dark
  • Cyborg
  • Darkly
  • Quartz
  • Slate
  • Solar
  • Superhero
  • Vapor

  • Default (No Skin)
  • No Skin
Collapse
Code Project
  1. Home
  2. General Programming
  3. C#
  4. Help with data update

Help with data update

Scheduled Pinned Locked Moved C#
helpdatabasesql-serversysadminquestion
3 Posts 2 Posters 0 Views 1 Watching
  • Oldest to Newest
  • Newest to Oldest
  • Most Votes
Reply
  • Reply as topic
Log in to reply
This topic has been deleted. Only users with topic management privileges can see it.
  • A Offline
    A Offline
    anton 09
    wrote on last edited by
    #1

    Hello, could anyone solve my problem. I have application working with MSSQL Server: there is one table "goods" (id, name) and another one - "info" (id, idgood1, idgood2, info), where idgood1 and idggod2 - foreign keys. In my application I need to present a DataGridView in such a way, _______| goods1 | goods2 | goods3 goods1 | info11 | ______ | ______ goods2 | ______ | ______ | info23 goods3 | info31 | ______ | info33 I select data from two tables ("goods", "info") in appropriate DataTable instances: GoodsDataTable and InfoDataTable. Then I CREATE (dynamically) one more DataTable - VisualDataTable, which IS what i need. Then I put VisualDataTable into DataSet, DataSet into BindingSource, and, finally, BindingSource into DataGridView. It's working. Until I want to update something! I tried to call SqlAdapter's Update method as for InfoDataTable as DataSet. But nothing happens. In general, how should I update data in case when "visual" part of DataGridView and database structure are different..? Another words, I take data from database, and put data into database with one table, and I edit data with another table.

    N 1 Reply Last reply
    0
    • A anton 09

      Hello, could anyone solve my problem. I have application working with MSSQL Server: there is one table "goods" (id, name) and another one - "info" (id, idgood1, idgood2, info), where idgood1 and idggod2 - foreign keys. In my application I need to present a DataGridView in such a way, _______| goods1 | goods2 | goods3 goods1 | info11 | ______ | ______ goods2 | ______ | ______ | info23 goods3 | info31 | ______ | info33 I select data from two tables ("goods", "info") in appropriate DataTable instances: GoodsDataTable and InfoDataTable. Then I CREATE (dynamically) one more DataTable - VisualDataTable, which IS what i need. Then I put VisualDataTable into DataSet, DataSet into BindingSource, and, finally, BindingSource into DataGridView. It's working. Until I want to update something! I tried to call SqlAdapter's Update method as for InfoDataTable as DataSet. But nothing happens. In general, how should I update data in case when "visual" part of DataGridView and database structure are different..? Another words, I take data from database, and put data into database with one table, and I edit data with another table.

      N Offline
      N Offline
      Nader Elshehabi
      wrote on last edited by
      #2

      Your design is a bit blur. What I understand form your post is that you combine two tables into one, this is called DataView object which should be in the SQL server layer of your program. Create a SqlCommand that creates a DataView combining both tables then make your SELECT/UPDATE commands on that view. Both tables will be updated accordingly. I hope I got you right.

      Regards:rose:

      A 1 Reply Last reply
      0
      • N Nader Elshehabi

        Your design is a bit blur. What I understand form your post is that you combine two tables into one, this is called DataView object which should be in the SQL server layer of your program. Create a SqlCommand that creates a DataView combining both tables then make your SELECT/UPDATE commands on that view. Both tables will be updated accordingly. I hope I got you right.

        Regards:rose:

        A Offline
        A Offline
        anton 09
        wrote on last edited by
        #3

        OK, I'll show an example "Goods" Table:

        id | name --------- 23 | foo1 24 | foo2 25 | foo3

        "Info" Table:

        id | idgood1 | idgood2 | info ----------------------------- 10 | _____23 | _____24 | inf1 11 | _____23 | _____25 | inf2 12 | _____24 | _____25 | inf3

        I want to see in DataGridView such structure (first row - row header, first column - column header):

        ____ | foo1 | foo2 | foo3 -------------------------- foo1 | ____ | inf1 | inf2 foo2 | ____ | ____ | inf3 foo3 | ____ | ____ | ____

        1 Reply Last reply
        0
        Reply
        • Reply as topic
        Log in to reply
        • Oldest to Newest
        • Newest to Oldest
        • Most Votes


        • Login

        • Don't have an account? Register

        • Login or register to search.
        • First post
          Last post
        0
        • Categories
        • Recent
        • Tags
        • Popular
        • World
        • Users
        • Groups