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
CODE PROJECT For Those Who Code
  • Home
  • Articles
  • FAQ
Community
  1. Home
  2. Database & SysAdmin
  3. Database
  4. SQL Application - stuck on the way I should update my Table

SQL Application - stuck on the way I should update my Table

Scheduled Pinned Locked Moved Database
databasehelpcsssql-serversysadmin
2 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.
  • P Offline
    P Offline
    ps0f0r
    wrote on last edited by
    #1

    Greetings! My name is Christos and I come from greece, happy to mmet you all! Anyways, I should start describing my problem. We use an ERP program in conjuction with SQL server and lots of tables that keep track of product records customers and all these kinds of stuff. I am building a fairly simple Warehouse Inventory Application. I have created a custom Inventory table that I would populate with records like {stock_code, Description, Quantity_remain, quantity_avail}. Those records already exist in 2 different tables in my database. The aim is that I want my program to fetch daily 10 random codes from those 2 tables bringing together the "columns" that my new custom table has +2 more editable columns: inventory, date, user with a query like this: select top 10 stck.code, stck.descr, stck.active, stck.group_code, stck.categ_code, stck_x_th.xwr_code, stck_x_th.thesi_code, stck_x_th.quant_remain from stck left outer join stck_x_th on stck.code = stck_x_th.stck_code order by newid(), I use the the stck table to fetch product info like its code,description,group_code,categ_code, and then I outer join the stck_x_th that contains records concerning quantities remaining or available asociated with each code and "places" those quantities reside. (those exact same columns are the ones my custom inventory table has) store them in a datagridview control, with only one editable column -inventory-, and then when the user fills out the inventory quantites, I want to save the datagrid "as it is" in my new custom table. I am creating a databound gridview control using one table adapter (which refers to the inventory table). Then I populate my table adapter using the forementioned query with a fillby method to populate the Datagrid (and therefore my Table in SQL) with the exact same values my query returned from the different tables. But whenever I try to update the table concurrency exceptions raise. It works like a charm if I enter the values in the grid cells manually my self but not if I populate the grid via a query and then hit update. Any suggestions please? I would appreciate it if you could bother posting some sample code. Thanks in Advance

    M 1 Reply Last reply
    0
    • P ps0f0r

      Greetings! My name is Christos and I come from greece, happy to mmet you all! Anyways, I should start describing my problem. We use an ERP program in conjuction with SQL server and lots of tables that keep track of product records customers and all these kinds of stuff. I am building a fairly simple Warehouse Inventory Application. I have created a custom Inventory table that I would populate with records like {stock_code, Description, Quantity_remain, quantity_avail}. Those records already exist in 2 different tables in my database. The aim is that I want my program to fetch daily 10 random codes from those 2 tables bringing together the "columns" that my new custom table has +2 more editable columns: inventory, date, user with a query like this: select top 10 stck.code, stck.descr, stck.active, stck.group_code, stck.categ_code, stck_x_th.xwr_code, stck_x_th.thesi_code, stck_x_th.quant_remain from stck left outer join stck_x_th on stck.code = stck_x_th.stck_code order by newid(), I use the the stck table to fetch product info like its code,description,group_code,categ_code, and then I outer join the stck_x_th that contains records concerning quantities remaining or available asociated with each code and "places" those quantities reside. (those exact same columns are the ones my custom inventory table has) store them in a datagridview control, with only one editable column -inventory-, and then when the user fills out the inventory quantites, I want to save the datagrid "as it is" in my new custom table. I am creating a databound gridview control using one table adapter (which refers to the inventory table). Then I populate my table adapter using the forementioned query with a fillby method to populate the Datagrid (and therefore my Table in SQL) with the exact same values my query returned from the different tables. But whenever I try to update the table concurrency exceptions raise. It works like a charm if I enter the values in the grid cells manually my self but not if I populate the grid via a query and then hit update. Any suggestions please? I would appreciate it if you could bother posting some sample code. Thanks in Advance

      M Offline
      M Offline
      Mycroft Holmes
      wrote on last edited by
      #2

      So if I understand this correctly you are querying the database, populating the datagridview and wanting to rely on the datagridviews update command to put the data back into the database. This is probably the ultimate corruption of a concept that I have ever seen, when MS supplied the DGV with command methods to do the CRUD work it is designed for retail work (it is a great disservice to the developers as this type of thing happens). What you are doing should be done totally in the database, it should be performed by a stored procedure and never have anything to do with the UI. You need to look into stored procedures and TSQL, data warehousing is always done on the server side.

      Never underestimate the power of human stupidity RAH

      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