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. Visual Basic
  4. problem updating datagrid

problem updating datagrid

Scheduled Pinned Locked Moved Visual Basic
databasehelpquestionannouncement
4 Posts 3 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.
  • M Offline
    M Offline
    mcm
    wrote on last edited by
    #1

    having performed an update in a datagrid, i get this message box: " insufficient key column information for updating or refreshing" (even though the table in the database updates successfully), why is this? Thanking you!

    D 1 Reply Last reply
    0
    • M mcm

      having performed an update in a datagrid, i get this message box: " insufficient key column information for updating or refreshing" (even though the table in the database updates successfully), why is this? Thanking you!

      D Offline
      D Offline
      Don Benson
      wrote on last edited by
      #2

      mcm wrote: having performed an update in a datagrid, i get this message box: " insufficient key column information for updating or refreshing" (even though the table in the database updates successfully) There could be a number of reasons for your problem. One of the most common reasons is that your data was retrieved from multiple tables. The other tables would like to try updating, but they can't because the primary key is not available in the retrieved data. If you could provide more specifics, you might get a more useful response. For example, what kind of data are you retrieving (Access, SQL, Oracle)? Are you using ADO, ODBC, or something else to get the data? We need enough information to "debug" the problem.

      A 1 Reply Last reply
      0
      • D Don Benson

        mcm wrote: having performed an update in a datagrid, i get this message box: " insufficient key column information for updating or refreshing" (even though the table in the database updates successfully) There could be a number of reasons for your problem. One of the most common reasons is that your data was retrieved from multiple tables. The other tables would like to try updating, but they can't because the primary key is not available in the retrieved data. If you could provide more specifics, you might get a more useful response. For example, what kind of data are you retrieving (Access, SQL, Oracle)? Are you using ADO, ODBC, or something else to get the data? We need enough information to "debug" the problem.

        A Offline
        A Offline
        Anonymous
        wrote on last edited by
        #3

        im so sorry for my lack of information - the following is code relating to populating the datagrid: Dim strType As String strType = DataComboType.Text Dim strDesc As String strDesc = DataComboDesc.Text 'selecting the appropriate values Dim findSQL As String findSQL = "SELECT Price.ProductCode, Product.Description, Price.Price " & _ " FROM ProductType INNER JOIN (Product INNER JOIN (PriceDescription INNER JOIN Price ON PriceDescription.PriceCode = Price.PriceCode) ON Product.Code = Price.ProductCode) ON ProductType.TypeCode = Product.TypeCode " & _ " WHERE (((PriceDescription.PriceDesc) = '" & strDesc & "') AND ((ProductType.Description)='" & strType & "'))" Set RS = Conn.Execute(findSQL) 'refreshing the grid Adodc3.RecordSource = findSQL DataGrid1.Visible = True Set DataGrid1.DataSource = Adodc3 Adodc3.Refresh 'DataGrid1.Refresh cmdSave.Enabled = True i wish to edit details in the grid once populated but it returns that error when i make any changes in the grid - its access im using in the backend. if you require anymore information, let me know - thank you so much for your time!

        D 1 Reply Last reply
        0
        • A Anonymous

          im so sorry for my lack of information - the following is code relating to populating the datagrid: Dim strType As String strType = DataComboType.Text Dim strDesc As String strDesc = DataComboDesc.Text 'selecting the appropriate values Dim findSQL As String findSQL = "SELECT Price.ProductCode, Product.Description, Price.Price " & _ " FROM ProductType INNER JOIN (Product INNER JOIN (PriceDescription INNER JOIN Price ON PriceDescription.PriceCode = Price.PriceCode) ON Product.Code = Price.ProductCode) ON ProductType.TypeCode = Product.TypeCode " & _ " WHERE (((PriceDescription.PriceDesc) = '" & strDesc & "') AND ((ProductType.Description)='" & strType & "'))" Set RS = Conn.Execute(findSQL) 'refreshing the grid Adodc3.RecordSource = findSQL DataGrid1.Visible = True Set DataGrid1.DataSource = Adodc3 Adodc3.Refresh 'DataGrid1.Refresh cmdSave.Enabled = True i wish to edit details in the grid once populated but it returns that error when i make any changes in the grid - its access im using in the backend. if you require anymore information, let me know - thank you so much for your time!

          D Offline
          D Offline
          Don Benson
          wrote on last edited by
          #4

          Anonymous wrote: findSQL = "SELECT Price.ProductCode, Product.Description, Price.Price " & _ " FROM ProductType INNER JOIN (Product INNER JOIN (PriceDescription INNER JOIN Price ON PriceDescription.PriceCode = Price.PriceCode) ON Product.Code = Price.ProductCode) ON ProductType.TypeCode = Product.TypeCode " & _ " WHERE (((PriceDescription.PriceDesc) = '" & strDesc & "') AND ((ProductType.Description)='" & strType & "'))" You are selecting data from the Price and Product tables. Which colunns are being edited? To update the Description, you need the primary key of the Product table to be included in the data. To update the ProductCode or Price columns, you need the primary key of the Price table in the data. Without the primary key columns in the data, the proper row can't be located for updating.

          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