Updating a Database

[b][red]This message was edited by James98765 at 2007-3-18 7:19:2[/red][/b][hr]
[b][red]This message was edited by James98765 at 2007-3-18 7:16:44[/red][/b][hr]
[b][red]This message was edited by James98765 at 2007-3-18 7:12:37[/red][/b][hr]
[b][red]This message was edited by James98765 at 2007-3-18 5:44:50[/red][/b][hr]
I am trying to make a program where I have four textboxes that will display text from 4 fields in a Microsoft Access Database. This works so far. I also want to be able to change the text in the text boxes and then click on a save button and have them update the text in the database. This is where I have a problem. Something is wrong with my code but I am not sure what. I am using this code for the update in the click event of the button.
[code]
Private m_dtGear As New DataTable
Private m_daDataAdapter As New OleDb.OleDbDataAdapter
m_dtGear.Rows(m_rowPosition)("Field1") = txtFP.Text
m_dtGear.Rows(m_rowPosition)("Field2") = txtRPM.Text
m_dtGear.Rows(m_rowPosition)("Field3") = txtGR.Text
m_dtGear.Rows(m_rowPosition)("Field4") = txtFD.Text
m_daDataAdapter = New OleDb.OleDbDataAdapter("Select * FROM Gear", m_cnADONetConnection)
m_daDataAdapter.Update(m_dtGear)
[/Code]

I get this error message during debug mode. When I click the button
[code]
An unhandled exception of type 'System.InvalidOperationException'
occurred in system.data.dll

Additional information: Update requires a valid UpdateCommand when passed DataRow collection with modified rows.
[/code]

Any help would be great because this has been very frustrating to try and figure out. I am kind of new to this so simpler would be better.
Oh yeah. I am using OLEDB
Thanks alot!
James
James98765
jamesparsons@cox.net
http://www.programmersheaven.com/c/Settings/messageboard.htm








Comments

  • : [b][red]This message was edited by James98765 at 2007-3-18 7:19:2[/red][/b][hr]
    : [b][red]This message was edited by James98765 at 2007-3-18 7:16:44[/red][/b][hr]
    : [b][red]This message was edited by James98765 at 2007-3-18 7:12:37[/red][/b][hr]
    : [b][red]This message was edited by James98765 at 2007-3-18 5:44:50[/red][/b][hr]
    : I am trying to make a program where I have four textboxes that will display text from 4 fields in a Microsoft Access Database. This works so far. I also want to be able to change the text in the text boxes and then click on a save button and have them update the text in the database. This is where I have a problem. Something is wrong with my code but I am not sure what. I am using this code for the update in the click event of the button.
    : [code]
    : Private m_dtGear As New DataTable
    : Private m_daDataAdapter As New OleDb.OleDbDataAdapter
    : m_dtGear.Rows(m_rowPosition)("Field1") = txtFP.Text
    : m_dtGear.Rows(m_rowPosition)("Field2") = txtRPM.Text
    : m_dtGear.Rows(m_rowPosition)("Field3") = txtGR.Text
    : m_dtGear.Rows(m_rowPosition)("Field4") = txtFD.Text
    : m_daDataAdapter = New OleDb.OleDbDataAdapter("Select * FROM Gear", m_cnADONetConnection)
    : m_daDataAdapter.Update(m_dtGear)
    : [/Code]
    :
    : I get this error message during debug mode. When I click the button
    : [code]
    : An unhandled exception of type 'System.InvalidOperationException'
    : occurred in system.data.dll
    :
    : Additional information: Update requires a valid UpdateCommand when passed DataRow collection with modified rows.
    : [/code]
    :
    : Any help would be great because this has been very frustrating to try and figure out. I am kind of new to this so simpler would be better.
    : Oh yeah. I am using OLEDB
    : Thanks alot!
    : James
    : James98765
    : jamesparsons@cox.net
    : http://www.programmersheaven.com/c/Settings/messageboard.htm
    :
    :
    :
    :
    :
    :
    :
    :
    :
    What version of visual basic are you running.


  • : : [b][red]This message was edited by James98765 at 2007-3-18 7:19:2[/red][/b][hr]
    : : [b][red]This message was edited by James98765 at 2007-3-18 7:16:44[/red][/b][hr]
    : : [b][red]This message was edited by James98765 at 2007-3-18 7:12:37[/red][/b][hr]
    : : [b][red]This message was edited by James98765 at 2007-3-18 5:44:50[/red][/b][hr]
    : : I am trying to make a program where I have four textboxes that will display text from 4 fields in a Microsoft Access Database. This works so far. I also want to be able to change the text in the text boxes and then click on a save button and have them update the text in the database. This is where I have a problem. Something is wrong with my code but I am not sure what. I am using this code for the update in the click event of the button.
    : : [code]
    : : Private m_dtGear As New DataTable
    : : Private m_daDataAdapter As New OleDb.OleDbDataAdapter
    : : m_dtGear.Rows(m_rowPosition)("Field1") = txtFP.Text
    : : m_dtGear.Rows(m_rowPosition)("Field2") = txtRPM.Text
    : : m_dtGear.Rows(m_rowPosition)("Field3") = txtGR.Text
    : : m_dtGear.Rows(m_rowPosition)("Field4") = txtFD.Text
    : : m_daDataAdapter = New OleDb.OleDbDataAdapter("Select * FROM Gear", m_cnADONetConnection)
    : : m_daDataAdapter.Update(m_dtGear)
    : : [/Code]
    : :
    : : I get this error message during debug mode. When I click the button
    : : [code]
    : : An unhandled exception of type 'System.InvalidOperationException'
    : : occurred in system.data.dll
    : :
    : : Additional information: Update requires a valid UpdateCommand when passed DataRow collection with modified rows.
    : : [/code]
    : :
    : : Any help would be great because this has been very frustrating to try and figure out. I am kind of new to this so simpler would be better.
    : : Oh yeah. I am using OLEDB
    : : Thanks alot!
    : : James
    : : James98765
    : : jamesparsons@cox.net
    : : http://www.programmersheaven.com/c/Settings/messageboard.htm
    : :
    : :
    : :
    : :
    : :
    : :
    : :
    : :
    : :
    : What version of visual basic are you running.
    :
    :
    : I am not entirely sure but when I looked on Help - About it said I have microsft visual studio 2003 version 7.1 and I am using Visual Basic. Net

    James
    James98765
    jamesparsons@cox.net
    http://www.programmersheaven.com/c/Settings/messageboard.htm

  • [b][red]This message was edited by jbassmanp at 2007-3-19 19:19:56[/red][/b][hr]
    [b][red]This message was edited by jbassmanp at 2007-3-19 19:17:24[/red][/b][hr]
    : : I am trying to make a program where I have four textboxes that will display text from 4 fields in a Microsoft Access Database. This works so far. I also want to be able to change the text in the text boxes and then click on a save button and have them update the text in the database. This is where I have a problem. Something is wrong with my code but I am not sure what. I am using this code for the update in the click event of the button.
    : : : [code]
    : : : Private m_dtGear As New DataTable
    : : : Private m_daDataAdapter As New OleDb.OleDbDataAdapter
    : : : m_dtGear.Rows(m_rowPosition)("Field1") = txtFP.Text
    : : : m_dtGear.Rows(m_rowPosition)("Field2") = txtRPM.Text
    : : : m_dtGear.Rows(m_rowPosition)("Field3") = txtGR.Text
    : : : m_dtGear.Rows(m_rowPosition)("Field4") = txtFD.Text
    : : : m_daDataAdapter = New OleDb.OleDbDataAdapter("Select * FROM Gear", m_cnADONetConnection)
    : : : m_daDataAdapter.Update(m_dtGear)
    : : : [/Code]
    : : :
    : : : I get this error message during debug mode. When I click the button
    : : : [code]
    : : : An unhandled exception of type 'System.InvalidOperationException'
    : : : occurred in system.data.dll
    : : :
    : : : Additional information: Update requires a valid UpdateCommand when passed DataRow collection with modified rows.
    : : : [/code]
    : : :
    : : : Any help would be great because this has been very frustrating to try and figure out. I am kind of new to this so simpler would be better.
    : : : Oh yeah. I am using OLEDB
    : : : Thanks alot!
    : : : James
    : : : James98765
    : : : jamesparsons@cox.net
    : : : http://www.programmersheaven.com/c/Settings/messageboard.htm
    : : :
    : : :
    : : :
    : : :
    : : :
    : : :
    : : :
    : : :
    : : :
    : : What version of visual basic are you running.
    : :
    : :
    : : I am not entirely sure but when I looked on Help - About it said I have microsft visual studio 2003 version 7.1 and I am using Visual Basic. Net
    :
    : James
    : James98765
    : jamesparsons@cox.net
    : http://www.programmersheaven.com/c/Settings/messageboard.htm
    :
    :
    James 2003 is not the lastest version of Visual Basic but it is good and has features that will automatically bind databases to your applications and build some of the routines for you. But looking at your code as it is now - you do not need to have the order the way it is now. If your prog is working but won't update then here as some changes:
    old lines
    1. Private m_dtGear As New DataTable
    2. Private m_daDataAdapter As New OleDb.OleDbDataAdapter
    3. m_dtGear.Rows(m_rowPosition)("Field1") = txtFP.Text
    4. m_dtGear.Rows(m_rowPosition)("Field2") = txtRPM.Text
    5. m_dtGear.Rows(m_rowPosition)("Field3") = txtGR.Text
    6. m_dtGear.Rows(m_rowPosition)("Field4") = txtFD.Text
    7. m_daDataAdapter = New OleDb.OleDbDataAdapter("Select * FROM Gear", m_cnADONetConnection)
    8. m_daDataAdapter.Update(m_dtGear)

    Line 7 needs to be moved somewhere before line 3. The index value(m_rowPosition) needs to be declare and established. ex

    0. Dim m_rowPosition as Integer
    1. Private m_dtGear As New DataTable
    2. Private m_daDataAdapter As New OleDb.OleDbDataAdapter
    3. m_daDataAdapter = New OleDb.OleDbDataAdapter("Select * FROM Gear", m_cnADONetConnection.
    .
    1. Private Sub savebutton
    2. m_rowPosition =Me.BindingContext(m_dtGear,"Gear").Position
    3. m_dtGear.Rows(m_rowPosition)("Field1") = txtFP.Text
    5. m_dtGear.Rows(m_rowPosition)("Field2") = txtRPM.Text
    6. m_dtGear.Rows(m_rowPosition)("Field3") = txtGR.Text
    7. m_dtGear.Rows(m_rowPosition)("Field4") = txtFD.Text
    8. m_daDataAdapter.Update(m_dtGear)
    9. End Sub

    this is just the beginning good coding





  • : [b][red]This message was edited by jbassmanp at 2007-3-19 19:19:56[/red][/b][hr]
    : [b][red]This message was edited by jbassmanp at 2007-3-19 19:17:24[/red][/b][hr]
    : : : I am trying to make a program where I have four textboxes that will display text from 4 fields in a Microsoft Access Database. This works so far. I also want to be able to change the text in the text boxes and then click on a save button and have them update the text in the database. This is where I have a problem. Something is wrong with my code but I am not sure what. I am using this code for the update in the click event of the button.
    : : : : [code]
    : : : : Private m_dtGear As New DataTable
    : : : : Private m_daDataAdapter As New OleDb.OleDbDataAdapter
    : : : : m_dtGear.Rows(m_rowPosition)("Field1") = txtFP.Text
    : : : : m_dtGear.Rows(m_rowPosition)("Field2") = txtRPM.Text
    : : : : m_dtGear.Rows(m_rowPosition)("Field3") = txtGR.Text
    : : : : m_dtGear.Rows(m_rowPosition)("Field4") = txtFD.Text
    : : : : m_daDataAdapter = New OleDb.OleDbDataAdapter("Select * FROM Gear", m_cnADONetConnection)
    : : : : m_daDataAdapter.Update(m_dtGear)
    : : : : [/Code]
    : : : :
    : : : : I get this error message during debug mode. When I click the button
    : : : : [code]
    : : : : An unhandled exception of type 'System.InvalidOperationException'
    : : : : occurred in system.data.dll
    : : : :
    : : : : Additional information: Update requires a valid UpdateCommand when passed DataRow collection with modified rows.
    : : : : [/code]
    : : : :
    : : : : Any help would be great because this has been very frustrating to try and figure out. I am kind of new to this so simpler would be better.
    : : : : Oh yeah. I am using OLEDB
    : : : : Thanks alot!
    : : : : James
    : : : : James98765
    : : : : jamesparsons@cox.net
    : : : : http://www.programmersheaven.com/c/Settings/messageboard.htm
    : : : :
    : : : :
    : : : :
    : : : :
    : : : :
    : : : :
    : : : :
    : : : :
    : : : :
    : : : What version of visual basic are you running.
    : : :
    : : :
    : : : I am not entirely sure but when I looked on Help - About it said I have microsft visual studio 2003 version 7.1 and I am using Visual Basic. Net
    : :
    : : James
    : : James98765
    : : jamesparsons@cox.net
    : : http://www.programmersheaven.com/c/Settings/messageboard.htm
    : :
    : :
    : James 2003 is not the lastest version of Visual Basic but it is good and has features that will automatically bind databases to your applications and build some of the routines for you. But looking at your code as it is now - you do not need to have the order the way it is now. If your prog is working but won't update then here as some changes:
    : old lines
    : 1. Private m_dtGear As New DataTable
    : 2. Private m_daDataAdapter As New OleDb.OleDbDataAdapter
    : 3. m_dtGear.Rows(m_rowPosition)("Field1") = txtFP.Text
    : 4. m_dtGear.Rows(m_rowPosition)("Field2") = txtRPM.Text
    : 5. m_dtGear.Rows(m_rowPosition)("Field3") = txtGR.Text
    : 6. m_dtGear.Rows(m_rowPosition)("Field4") = txtFD.Text
    : 7. m_daDataAdapter = New OleDb.OleDbDataAdapter("Select * FROM Gear", m_cnADONetConnection)
    : 8. m_daDataAdapter.Update(m_dtGear)
    :
    : Line 7 needs to be moved somewhere before line 3. The index value(m_rowPosition) needs to be declare and established. ex
    :
    : 0. Dim m_rowPosition as Integer
    : 1. Private m_dtGear As New DataTable
    : 2. Private m_daDataAdapter As New OleDb.OleDbDataAdapter
    : 3. m_daDataAdapter = New OleDb.OleDbDataAdapter("Select * FROM Gear", m_cnADONetConnection.
    : .
    : 1. Private Sub savebutton
    : 2. m_rowPosition =Me.BindingContext(m_dtGear,"Gear").Position
    : 3. m_dtGear.Rows(m_rowPosition)("Field1") = txtFP.Text
    : 5. m_dtGear.Rows(m_rowPosition)("Field2") = txtRPM.Text
    : 6. m_dtGear.Rows(m_rowPosition)("Field3") = txtGR.Text
    : 7. m_dtGear.Rows(m_rowPosition)("Field4") = txtFD.Text
    : 8. m_daDataAdapter.Update(m_dtGear)
    : 9. End Sub
    :
    : this is just the beginning good coding

    Thanks for your help you gave me some good insight except now when I moved the code the way you said it just gives me this message
    [code]
    An unhandled exception of type 'System.InvalidOperationException' occurred in system.data.dll

    Additional information: Dynamic SQL generation for the UpdateCommand is not supported against a SelectCommand that does not return any key column information.
    [/code]
    James
    James98765
    jamesparsons@cox.net
    http://www.programmersheaven.com/c/Settings/messageboard.htm

  • : [b][red]This message was edited by jbassmanp at 2007-3-19 19:19:56[/red][/b][hr]
    : [b][red]This message was edited by jbassmanp at 2007-3-19 19:17:24[/red][/b][hr]
    : : : I am trying to make a program where I have four textboxes that will display text from 4 fields in a Microsoft Access Database. This works so far. I also want to be able to change the text in the text boxes and then click on a save button and have them update the text in the database. This is where I have a problem. Something is wrong with my code but I am not sure what. I am using this code for the update in the click event of the button.
    : : : : [code]
    : : : : Private m_dtGear As New DataTable
    : : : : Private m_daDataAdapter As New OleDb.OleDbDataAdapter
    : : : : m_dtGear.Rows(m_rowPosition)("Field1") = txtFP.Text
    : : : : m_dtGear.Rows(m_rowPosition)("Field2") = txtRPM.Text
    : : : : m_dtGear.Rows(m_rowPosition)("Field3") = txtGR.Text
    : : : : m_dtGear.Rows(m_rowPosition)("Field4") = txtFD.Text
    : : : : m_daDataAdapter = New OleDb.OleDbDataAdapter("Select * FROM Gear", m_cnADONetConnection)
    : : : : m_daDataAdapter.Update(m_dtGear)
    : : : : [/Code]
    : : : :
    : : : : I get this error message during debug mode. When I click the button
    : : : : [code]
    : : : : An unhandled exception of type 'System.InvalidOperationException'
    : : : : occurred in system.data.dll
    : : : :
    : : : : Additional information: Update requires a valid UpdateCommand when passed DataRow collection with modified rows.
    : : : : [/code]
    : : : :
    : : : : Any help would be great because this has been very frustrating to try and figure out. I am kind of new to this so simpler would be better.
    : : : : Oh yeah. I am using OLEDB
    : : : : Thanks alot!
    : : : : James
    : : : : James98765
    : : : : jamesparsons@cox.net
    : : : : http://www.programmersheaven.com/c/Settings/messageboard.htm
    : : : :
    : : : :
    : : : :
    : : : :
    : : : :
    : : : :
    : : : :
    : : : :
    : : : :
    : : : What version of visual basic are you running.
    : : :
    : : :
    : : : I am not entirely sure but when I looked on Help - About it said I have microsft visual studio 2003 version 7.1 and I am using Visual Basic. Net
    : :
    : : James
    : : James98765
    : : jamesparsons@cox.net
    : : http://www.programmersheaven.com/c/Settings/messageboard.htm
    : :
    : :
    : James 2003 is not the lastest version of Visual Basic but it is good and has features that will automatically bind databases to your applications and build some of the routines for you. But looking at your code as it is now - you do not need to have the order the way it is now. If your prog is working but won't update then here as some changes:
    : old lines
    : 1. Private m_dtGear As New DataTable
    : 2. Private m_daDataAdapter As New OleDb.OleDbDataAdapter
    : 3. m_dtGear.Rows(m_rowPosition)("Field1") = txtFP.Text
    : 4. m_dtGear.Rows(m_rowPosition)("Field2") = txtRPM.Text
    : 5. m_dtGear.Rows(m_rowPosition)("Field3") = txtGR.Text
    : 6. m_dtGear.Rows(m_rowPosition)("Field4") = txtFD.Text
    : 7. m_daDataAdapter = New OleDb.OleDbDataAdapter("Select * FROM Gear", m_cnADONetConnection)
    : 8. m_daDataAdapter.Update(m_dtGear)
    :
    : Line 7 needs to be moved somewhere before line 3. The index value(m_rowPosition) needs to be declare and established. ex
    :
    : 0. Dim m_rowPosition as Integer
    : 1. Private m_dtGear As New DataTable
    : 2. Private m_daDataAdapter As New OleDb.OleDbDataAdapter
    : 3. m_daDataAdapter = New OleDb.OleDbDataAdapter("Select * FROM Gear", m_cnADONetConnection.
    : .
    : 1. Private Sub savebutton
    : 2. m_rowPosition =Me.BindingContext(m_dtGear,"Gear").Position
    : 3. m_dtGear.Rows(m_rowPosition)("Field1") = txtFP.Text
    : 5. m_dtGear.Rows(m_rowPosition)("Field2") = txtRPM.Text
    : 6. m_dtGear.Rows(m_rowPosition)("Field3") = txtGR.Text
    : 7. m_dtGear.Rows(m_rowPosition)("Field4") = txtFD.Text
    : 8. m_daDataAdapter.Update(m_dtGear)
    : 9. End Sub
    :
    : this is just the beginning good coding

    Sorry to bother you again but I just moved the code again a little bit and I am not sure if I am just replacing old problems with new problems but I used your
    [code]
    m_rowPosition =Me.BindingContext(m_dtGear,"Gear").Position
    [/code]
    line and got this error message
    [code]
    An unhandled exception of type 'System.ArgumentException' occurred in system.windows.forms.dll

    Additional information: Cannot create a child list for field Table.
    [/code]
    James
    James98765
    jamesparsons@cox.net
    http://www.programmersheaven.com/c/Settings/messageboard.htm

  • : : [b][red]This message was edited by jbassmanp at 2007-3-19 19:19:56[/red][/b][hr]
    : : [b][red]This message was edited by jbassmanp at 2007-3-19 19:17:24[/red][/b][hr]
    : : : : I am trying to make a program where I have four textboxes that will display text from 4 fields in a Microsoft Access Database. This works so far. I also want to be able to change the text in the text boxes and then click on a save button and have them update the text in the database. This is where I have a problem. Something is wrong with my code but I am not sure what. I am using this code for the update in the click event of the button.
    : : : : : [code]
    : : : : : Private m_dtGear As New DataTable
    : : : : : Private m_daDataAdapter As New OleDb.OleDbDataAdapter
    : : : : : m_dtGear.Rows(m_rowPosition)("Field1") = txtFP.Text
    : : : : : m_dtGear.Rows(m_rowPosition)("Field2") = txtRPM.Text
    : : : : : m_dtGear.Rows(m_rowPosition)("Field3") = txtGR.Text
    : : : : : m_dtGear.Rows(m_rowPosition)("Field4") = txtFD.Text
    : : : : : m_daDataAdapter = New OleDb.OleDbDataAdapter("Select * FROM Gear", m_cnADONetConnection)
    : : : : : m_daDataAdapter.Update(m_dtGear)
    : : : : : [/Code]
    : : : : :
    : : : : : I get this error message during debug mode. When I click the button
    : : : : : [code]
    : : : : : An unhandled exception of type 'System.InvalidOperationException'
    : : : : : occurred in system.data.dll
    : : : : :
    : : : : : Additional information: Update requires a valid UpdateCommand when passed DataRow collection with modified rows.
    : : : : : [/code]
    : : : : :
    : : : : : Any help would be great because this has been very frustrating to try and figure out. I am kind of new to this so simpler would be better.
    : : : : : Oh yeah. I am using OLEDB
    : : : : : Thanks alot!
    : : : : : James
    : : : : : James98765
    : : : : : jamesparsons@cox.net
    : : : : : http://www.programmersheaven.com/c/Settings/messageboard.htm
    : : : : :
    : : : : :
    : : : : :
    : : : : :
    : : : : :
    : : : : :
    : : : : :
    : : : : :
    : : : : :
    : : : : What version of visual basic are you running.
    : : : :
    : : : :
    : : : : I am not entirely sure but when I looked on Help - About it said I have microsft visual studio 2003 version 7.1 and I am using Visual Basic. Net
    : : :
    : : : James
    : : : James98765
    : : : jamesparsons@cox.net
    : : : http://www.programmersheaven.com/c/Settings/messageboard.htm
    : : :
    : : :
    : : James 2003 is not the lastest version of Visual Basic but it is good and has features that will automatically bind databases to your applications and build some of the routines for you. But looking at your code as it is now - you do not need to have the order the way it is now. If your prog is working but won't update then here as some changes:
    : : old lines
    : : 1. Private m_dtGear As New DataTable
    : : 2. Private m_daDataAdapter As New OleDb.OleDbDataAdapter
    : : 3. m_dtGear.Rows(m_rowPosition)("Field1") = txtFP.Text
    : : 4. m_dtGear.Rows(m_rowPosition)("Field2") = txtRPM.Text
    : : 5. m_dtGear.Rows(m_rowPosition)("Field3") = txtGR.Text
    : : 6. m_dtGear.Rows(m_rowPosition)("Field4") = txtFD.Text
    : : 7. m_daDataAdapter = New OleDb.OleDbDataAdapter("Select * FROM Gear", m_cnADONetConnection)
    : : 8. m_daDataAdapter.Update(m_dtGear)
    : :
    : : Line 7 needs to be moved somewhere before line 3. The index value(m_rowPosition) needs to be declare and established. ex
    : :
    : : 0. Dim m_rowPosition as Integer
    : : 1. Private m_dtGear As New DataTable
    : : 2. Private m_daDataAdapter As New OleDb.OleDbDataAdapter
    : : 3. m_daDataAdapter = New OleDb.OleDbDataAdapter("Select * FROM Gear", m_cnADONetConnection.
    : : .
    : : 1. Private Sub savebutton
    : : 2. m_rowPosition =Me.BindingContext(m_dtGear,"Gear").Position
    : : 3. m_dtGear.Rows(m_rowPosition)("Field1") = txtFP.Text
    : : 5. m_dtGear.Rows(m_rowPosition)("Field2") = txtRPM.Text
    : : 6. m_dtGear.Rows(m_rowPosition)("Field3") = txtGR.Text
    : : 7. m_dtGear.Rows(m_rowPosition)("Field4") = txtFD.Text
    : : 8. m_daDataAdapter.Update(m_dtGear)
    : : 9. End Sub
    : :
    : : this is just the beginning good coding
    :
    : Sorry to bother you again but I just moved the code again a little bit and I am not sure if I am just replacing old problems with new problems but I used your
    : [code]
    : m_rowPosition =Me.BindingContext(m_dtGear,"Gear").Position
    : [/code]
    : line and got this error message
    : [code]
    : An unhandled exception of type 'System.ArgumentException' occurred in system.windows.forms.dll
    :
    : Additional information: Cannot create a child list for field Table.
    : [/code]
    : James
    : James98765
    : jamesparsons@cox.net
    : http://www.programmersheaven.com/c/Settings/messageboard.htm
    :
    :
    James do me a favor add an item to your project. This item will be a DataForm. When you do it will force you, by way of a data wizard to bound your access database to this form if you choice it as your data source, which you should. It will create a form for you with much of the basic coding routines aready there. You only need to add other coding matters to it. With this process you can look at the way VB2003 does things and it will teach you how to do these things.... You can add to this form what ever you want but it will help you out greatly. Try it, and let me know how it works it will not take long....


  • : : : [b][red]This message was edited by jbassmanp at 2007-3-19 19:19:56[/red][/b][hr]
    : : : [b][red]This message was edited by jbassmanp at 2007-3-19 19:17:24[/red][/b][hr]
    : : : : : I am trying to make a program where I have four textboxes that will display text from 4 fields in a Microsoft Access Database. This works so far. I also want to be able to change the text in the text boxes and then click on a save button and have them update the text in the database. This is where I have a problem. Something is wrong with my code but I am not sure what. I am using this code for the update in the click event of the button.
    : : : : : : [code]
    : : : : : : Private m_dtGear As New DataTable
    : : : : : : Private m_daDataAdapter As New OleDb.OleDbDataAdapter
    : : : : : : m_dtGear.Rows(m_rowPosition)("Field1") = txtFP.Text
    : : : : : : m_dtGear.Rows(m_rowPosition)("Field2") = txtRPM.Text
    : : : : : : m_dtGear.Rows(m_rowPosition)("Field3") = txtGR.Text
    : : : : : : m_dtGear.Rows(m_rowPosition)("Field4") = txtFD.Text
    : : : : : : m_daDataAdapter = New OleDb.OleDbDataAdapter("Select * FROM Gear", m_cnADONetConnection)
    : : : : : : m_daDataAdapter.Update(m_dtGear)
    : : : : : : [/Code]
    : : : : : :
    : : : : : : I get this error message during debug mode. When I click the button
    : : : : : : [code]
    : : : : : : An unhandled exception of type 'System.InvalidOperationException'
    : : : : : : occurred in system.data.dll
    : : : : : :
    : : : : : : Additional information: Update requires a valid UpdateCommand when passed DataRow collection with modified rows.
    : : : : : : [/code]
    : : : : : :
    : : : : : : Any help would be great because this has been very frustrating to try and figure out. I am kind of new to this so simpler would be better.
    : : : : : : Oh yeah. I am using OLEDB
    : : : : : : Thanks alot!
    : : : : : : James
    : : : : : : James98765
    : : : : : : jamesparsons@cox.net
    : : : : : : http://www.programmersheaven.com/c/Settings/messageboard.htm
    : : : : : :
    : : : : : :
    : : : : : :
    : : : : : :
    : : : : : :
    : : : : : :
    : : : : : :
    : : : : : :
    : : : : : :
    : : : : : What version of visual basic are you running.
    : : : : :
    : : : : :
    : : : : : I am not entirely sure but when I looked on Help - About it said I have microsft visual studio 2003 version 7.1 and I am using Visual Basic. Net
    : : : :
    : : : : James
    : : : : James98765
    : : : : jamesparsons@cox.net
    : : : : http://www.programmersheaven.com/c/Settings/messageboard.htm
    : : : :
    : : : :
    : : : James 2003 is not the lastest version of Visual Basic but it is good and has features that will automatically bind databases to your applications and build some of the routines for you. But looking at your code as it is now - you do not need to have the order the way it is now. If your prog is working but won't update then here as some changes:
    : : : old lines
    : : : 1. Private m_dtGear As New DataTable
    : : : 2. Private m_daDataAdapter As New OleDb.OleDbDataAdapter
    : : : 3. m_dtGear.Rows(m_rowPosition)("Field1") = txtFP.Text
    : : : 4. m_dtGear.Rows(m_rowPosition)("Field2") = txtRPM.Text
    : : : 5. m_dtGear.Rows(m_rowPosition)("Field3") = txtGR.Text
    : : : 6. m_dtGear.Rows(m_rowPosition)("Field4") = txtFD.Text
    : : : 7. m_daDataAdapter = New OleDb.OleDbDataAdapter("Select * FROM Gear", m_cnADONetConnection)
    : : : 8. m_daDataAdapter.Update(m_dtGear)
    : : :
    : : : Line 7 needs to be moved somewhere before line 3. The index value(m_rowPosition) needs to be declare and established. ex
    : : :
    : : : 0. Dim m_rowPosition as Integer
    : : : 1. Private m_dtGear As New DataTable
    : : : 2. Private m_daDataAdapter As New OleDb.OleDbDataAdapter
    : : : 3. m_daDataAdapter = New OleDb.OleDbDataAdapter("Select * FROM Gear", m_cnADONetConnection.
    : : : .
    : : : 1. Private Sub savebutton
    : : : 2. m_rowPosition =Me.BindingContext(m_dtGear,"Gear").Position
    : : : 3. m_dtGear.Rows(m_rowPosition)("Field1") = txtFP.Text
    : : : 5. m_dtGear.Rows(m_rowPosition)("Field2") = txtRPM.Text
    : : : 6. m_dtGear.Rows(m_rowPosition)("Field3") = txtGR.Text
    : : : 7. m_dtGear.Rows(m_rowPosition)("Field4") = txtFD.Text
    : : : 8. m_daDataAdapter.Update(m_dtGear)
    : : : 9. End Sub
    : : :
    : : : this is just the beginning good coding
    : :
    : : Sorry to bother you again but I just moved the code again a little bit and I am not sure if I am just replacing old problems with new problems but I used your
    : : [code]
    : : m_rowPosition =Me.BindingContext(m_dtGear,"Gear").Position
    : : [/code]
    : : line and got this error message
    : : [code]
    : : An unhandled exception of type 'System.ArgumentException' occurred in system.windows.forms.dll
    : :
    : : Additional information: Cannot create a child list for field Table.
    : : [/code]
    : : James
    : : James98765
    : : jamesparsons@cox.net
    : : http://www.programmersheaven.com/c/Settings/messageboard.htm
    : :
    : :
    : James do me a favor add an item to your project. This item will be a DataForm. When you do it will force you, by way of a data wizard to bound your access database to this form if you choice it as your data source, which you should. It will create a form for you with much of the basic coding routines aready there. You only need to add other coding matters to it. With this process you can look at the way VB2003 does things and it will teach you how to do these things.... You can add to this form what ever you want but it will help you out greatly. Try it, and let me know how it works it will not take long....
    :
    :
    :
    Thanks alot for the suggestion. THis helped me see how things worked a little better. I think I might be able to get things moving now. Thanks for the input!

    James
    James98765
    jamesparsons@cox.net
    http://www.programmersheaven.com/c/Settings/messageboard.htm

  • : : : [b][red]This message was edited by jbassmanp at 2007-3-19 19:19:56[/red][/b][hr]
    : : : [b][red]This message was edited by jbassmanp at 2007-3-19 19:17:24[/red][/b][hr]
    : : : : : I am trying to make a program where I have four textboxes that will display text from 4 fields in a Microsoft Access Database. This works so far. I also want to be able to change the text in the text boxes and then click on a save button and have them update the text in the database. This is where I have a problem. Something is wrong with my code but I am not sure what. I am using this code for the update in the click event of the button.
    : : : : : : [code]
    : : : : : : Private m_dtGear As New DataTable
    : : : : : : Private m_daDataAdapter As New OleDb.OleDbDataAdapter
    : : : : : : m_dtGear.Rows(m_rowPosition)("Field1") = txtFP.Text
    : : : : : : m_dtGear.Rows(m_rowPosition)("Field2") = txtRPM.Text
    : : : : : : m_dtGear.Rows(m_rowPosition)("Field3") = txtGR.Text
    : : : : : : m_dtGear.Rows(m_rowPosition)("Field4") = txtFD.Text
    : : : : : : m_daDataAdapter = New OleDb.OleDbDataAdapter("Select * FROM Gear", m_cnADONetConnection)
    : : : : : : m_daDataAdapter.Update(m_dtGear)
    : : : : : : [/Code]
    : : : : : :
    : : : : : : I get this error message during debug mode. When I click the button
    : : : : : : [code]
    : : : : : : An unhandled exception of type 'System.InvalidOperationException'
    : : : : : : occurred in system.data.dll
    : : : : : :
    : : : : : : Additional information: Update requires a valid UpdateCommand when passed DataRow collection with modified rows.
    : : : : : : [/code]
    : : : : : :
    : : : : : : Any help would be great because this has been very frustrating to try and figure out. I am kind of new to this so simpler would be better.
    : : : : : : Oh yeah. I am using OLEDB
    : : : : : : Thanks alot!
    : : : : : : James
    : : : : : : James98765
    : : : : : : jamesparsons@cox.net
    : : : : : : http://www.programmersheaven.com/c/Settings/messageboard.htm
    : : : : : :
    : : : : : :
    : : : : : :
    : : : : : :
    : : : : : :
    : : : : : :
    : : : : : :
    : : : : : :
    : : : : : :
    : : : : : What version of visual basic are you running.
    : : : : :
    : : : : :
    : : : : : I am not entirely sure but when I looked on Help - About it said I have microsft visual studio 2003 version 7.1 and I am using Visual Basic. Net
    : : : :
    : : : : James
    : : : : James98765
    : : : : jamesparsons@cox.net
    : : : : http://www.programmersheaven.com/c/Settings/messageboard.htm
    : : : :
    : : : :
    : : : James 2003 is not the lastest version of Visual Basic but it is good and has features that will automatically bind databases to your applications and build some of the routines for you. But looking at your code as it is now - you do not need to have the order the way it is now. If your prog is working but won't update then here as some changes:
    : : : old lines
    : : : 1. Private m_dtGear As New DataTable
    : : : 2. Private m_daDataAdapter As New OleDb.OleDbDataAdapter
    : : : 3. m_dtGear.Rows(m_rowPosition)("Field1") = txtFP.Text
    : : : 4. m_dtGear.Rows(m_rowPosition)("Field2") = txtRPM.Text
    : : : 5. m_dtGear.Rows(m_rowPosition)("Field3") = txtGR.Text
    : : : 6. m_dtGear.Rows(m_rowPosition)("Field4") = txtFD.Text
    : : : 7. m_daDataAdapter = New OleDb.OleDbDataAdapter("Select * FROM Gear", m_cnADONetConnection)
    : : : 8. m_daDataAdapter.Update(m_dtGear)
    : : :
    : : : Line 7 needs to be moved somewhere before line 3. The index value(m_rowPosition) needs to be declare and established. ex
    : : :
    : : : 0. Dim m_rowPosition as Integer
    : : : 1. Private m_dtGear As New DataTable
    : : : 2. Private m_daDataAdapter As New OleDb.OleDbDataAdapter
    : : : 3. m_daDataAdapter = New OleDb.OleDbDataAdapter("Select * FROM Gear", m_cnADONetConnection.
    : : : .
    : : : 1. Private Sub savebutton
    : : : 2. m_rowPosition =Me.BindingContext(m_dtGear,"Gear").Position
    : : : 3. m_dtGear.Rows(m_rowPosition)("Field1") = txtFP.Text
    : : : 5. m_dtGear.Rows(m_rowPosition)("Field2") = txtRPM.Text
    : : : 6. m_dtGear.Rows(m_rowPosition)("Field3") = txtGR.Text
    : : : 7. m_dtGear.Rows(m_rowPosition)("Field4") = txtFD.Text
    : : : 8. m_daDataAdapter.Update(m_dtGear)
    : : : 9. End Sub
    : : :
    : : : this is just the beginning good coding
    : :
    : : Sorry to bother you again but I just moved the code again a little bit and I am not sure if I am just replacing old problems with new problems but I used your
    : : [code]
    : : m_rowPosition =Me.BindingContext(m_dtGear,"Gear").Position
    : : [/code]
    : : line and got this error message
    : : [code]
    : : An unhandled exception of type 'System.ArgumentException' occurred in system.windows.forms.dll
    : :
    : : Additional information: Cannot create a child list for field Table.
    : : [/code]
    : : James
    : : James98765
    : : jamesparsons@cox.net
    : : http://www.programmersheaven.com/c/Settings/messageboard.htm
    : :
    : :
    : James do me a favor add an item to your project. This item will be a DataForm. When you do it will force you, by way of a data wizard to bound your access database to this form if you choice it as your data source, which you should. It will create a form for you with much of the basic coding routines aready there. You only need to add other coding matters to it. With this process you can look at the way VB2003 does things and it will teach you how to do these things.... You can add to this form what ever you want but it will help you out greatly. Try it, and let me know how it works it will not take long....
    :
    :
    :
    Sorry to keep bothering you but I think this will be my last question. When I run the DataForm in debug mode and change some things on the DataTable and click update I get the same message that gave me problems in the beginning but this time unstead of breaking the code it gives me the message in an error message. This Message:
    [code]
    Additional information: Update requires a valid UpdateCommand when passed DataRow collection with modified rows.
    [/code]
    Do you think that this could just be a problem with my computer? My dad who is a programmer, an old one, told me that it is possible that my datatable could be set to read only. Is this possible? and if so how do I fix it
    Sorry!!!!!!!!!!
    James
    James98765
    jamesparsons@cox.net
    http://www.programmersheaven.com/c/Settings/messageboard.htm


  • : : James do me a favor add an item to your project. This item will be a DataForm. When you do it will force you, by way of a data wizard to bound your access database to this form if you choice it as your data source, which you should. It will create a form for you with much of the basic coding routines aready there. You only need to add other coding matters to it. With this process you can look at the way VB2003 does things and it will teach you how to do these things.... You can add to this form what ever you want but it will help you out greatly. Try it, and let me know how it works it will not take long....
    : :
    : :
    : :
    : Sorry to keep bothering you but I think this will be my last question. When I run the DataForm in debug mode and change some things on the DataTable and click update I get the same message that gave me problems in the beginning but this time unstead of breaking the code it gives me the message in an error message. This Message:
    : [code]
    : Additional information: Update requires a valid UpdateCommand when passed DataRow collection with modified rows.
    : [/code]
    : Do you think that this could just be a problem with my computer? My dad who is a programmer, an old one, told me that it is possible that my datatable could be set to read only. Is this possible? and if so how do I fix it
    : Sorry!!!!!!!!!!
    : James
    : James98765
    : jamesparsons@cox.net
    : http://www.programmersheaven.com/c/Settings/messageboard.htm
    :
    :
    What did you change on the table? If you change something that is critical the update information/command may not have that change and thus the error message. When I change something I check all related links and rebuild with new updates command SOoooo what kind of changes did you make....


  • :
    : : : James do me a favor add an item to your project. This item will be a DataForm. When you do it will force you, by way of a data wizard to bound your access database to this form if you choice it as your data source, which you should. It will create a form for you with much of the basic coding routines aready there. You only need to add other coding matters to it. With this process you can look at the way VB2003 does things and it will teach you how to do these things.... You can add to this form what ever you want but it will help you out greatly. Try it, and let me know how it works it will not take long....
    : : :
    : : :
    : : :
    : : Sorry to keep bothering you but I think this will be my last question. When I run the DataForm in debug mode and change some things on the DataTable and click update I get the same message that gave me problems in the beginning but this time unstead of breaking the code it gives me the message in an error message. This Message:
    : : [code]
    : : Additional information: Update requires a valid UpdateCommand when passed DataRow collection with modified rows.
    : : [/code]
    : : Do you think that this could just be a problem with my computer? My dad who is a programmer, an old one, told me that it is possible that my datatable could be set to read only. Is this possible? and if so how do I fix it
    : : Sorry!!!!!!!!!!
    : : James
    : : James98765
    : : jamesparsons@cox.net
    : : http://www.programmersheaven.com/c/Settings/messageboard.htm
    : :
    : :
    : What did you change on the table? If you change something that is critical the update information/command may not have that change and thus the error message. When I change something I check all related links and rebuild with new updates command SOoooo what kind of changes did you make....
    :
    :
    :
    All I did was change one of the cells(I think thats what you call them) from 2.66 to 2.67. Then I clicked update and got the error message. I am not sure what kind of change you would call that but it didn't seem like it was a durastic change that would do hurt the update command. And this isn't an isolated incident. Anytime I change the text anywhere in the table in any cell and click update I get this error message. I understand if this problem is unsolvable. Thanks alot for your help
    James
    James98765
    jamesparsons@cox.net
    http://www.programmersheaven.com/c/Settings/messageboard.htm

  • : :
    : : : : James do me a favor add an item to your project. This item will be a DataForm. When you do it will force you, by way of a data wizard to bound your access database to this form if you choice it as your data source, which you should. It will create a form for you with much of the basic coding routines aready there. You only need to add other coding matters to it. With this process you can look at the way VB2003 does things and it will teach you how to do these things.... You can add to this form what ever you want but it will help you out greatly. Try it, and let me know how it works it will not take long....
    : : : :
    : : : :
    : : : :
    : : : Sorry to keep bothering you but I think this will be my last question. When I run the DataForm in debug mode and change some things on the DataTable and click update I get the same message that gave me problems in the beginning but this time unstead of breaking the code it gives me the message in an error message. This Message:
    : : : [code]
    : : : Additional information: Update requires a valid UpdateCommand when passed DataRow collection with modified rows.
    : : : [/code]
    : : : Do you think that this could just be a problem with my computer? My dad who is a programmer, an old one, told me that it is possible that my datatable could be set to read only. Is this possible? and if so how do I fix it
    : : : Sorry!!!!!!!!!!
    : : : James
    : : : James98765
    : : : jamesparsons@cox.net
    : : : http://www.programmersheaven.com/c/Settings/messageboard.htm
    : : :
    : : :
    : : What did you change on the table? If you change something that is critical the update information/command may not have that change and thus the error message. When I change something I check all related links and rebuild with new updates command SOoooo what kind of changes did you make....
    : :
    : :
    : :
    : All I did was change one of the cells(I think thats what you call them) from 2.66 to 2.67. Then I clicked update and got the error message. I am not sure what kind of change you would call that but it didn't seem like it was a durastic change that would do hurt the update command. And this isn't an isolated incident. Anytime I change the text anywhere in the table in any cell and click update I get this error message. I understand if this problem is unsolvable. Thanks alot for your help
    : James
    : James98765
    : jamesparsons@cox.net
    : http://www.programmersheaven.com/c/Settings/messageboard.htm
    :
    :
    So I see you chose to use a DataGrid instead of Textbox/Single Record method. I thought you wanted Textboxes. But cells in the grid should work just as eaily as the textbox. Hey can I send you something to look at using your email address....


  • [b][red]This message was edited by HackmanC at 2007-3-22 16:28:13[/red][/b][hr]
    You need a OleDbCommandBuilder Class.

    Provides a means of automatically generating single-table commands used to reconcile changes made to a DataSet with the associated database. This class cannot be inherited.

    The OleDbDataAdapter does not automatically generate the SQL statements required to reconcile changes made to a DataSet with the associated data source. However, you can create an OleDbCommandBuilder object to automatically generate SQL statements for single-table updates if you set the SelectCommand property of the OleDbDataAdapter. Then, any additional SQL statements that you do not set are generated by the OleDbCommandBuilder.


    [code]
    Private m_dtGear As New DataTable
    Private m_daDataAdapter As New OleDb.OleDbDataAdapter
    m_dtGear.Rows(m_rowPosition)("Field1") = txtFP.Text
    m_dtGear.Rows(m_rowPosition)("Field2") = txtRPM.Text
    m_dtGear.Rows(m_rowPosition)("Field3") = txtGR.Text
    m_dtGear.Rows(m_rowPosition)("Field4") = txtFD.Text
    m_daDataAdapter = New OleDb.OleDbDataAdapter("Select * FROM Gear", m_cnADONetConnection)
    [green]Rem YOU HAVE THE SELECT * FROM ... BUT YOU NEED THE UPDATE ... THE DELETE ... ETC.[/green]
    [red]Dim custCB As OleDbCommandBuilder = New OleDbCommandBuilder (m_daDataAdapter)[/red]
    m_daDataAdapter.Update(m_dtGear)
    [/Code]

    ---------------------------
    : I am trying to make a program where I have four textboxes that will display text from 4 fields in a Microsoft Access Database. This works so far. I also want to be able to change the text in the text boxes and then click on a save button and have them update the text in the database. This is where I have a problem. Something is wrong with my code but I am not sure what. I am using this code for the update in the click event of the button.
    : [code]
    : Private m_dtGear As New DataTable
    : Private m_daDataAdapter As New OleDb.OleDbDataAdapter
    : m_dtGear.Rows(m_rowPosition)("Field1") = txtFP.Text
    : m_dtGear.Rows(m_rowPosition)("Field2") = txtRPM.Text
    : m_dtGear.Rows(m_rowPosition)("Field3") = txtGR.Text
    : m_dtGear.Rows(m_rowPosition)("Field4") = txtFD.Text
    : m_daDataAdapter = New OleDb.OleDbDataAdapter("Select * FROM Gear", m_cnADONetConnection)
    : m_daDataAdapter.Update(m_dtGear)
    : [/Code]
    :
    : I get this error message during debug mode. When I click the button
    : [code]
    : An unhandled exception of type 'System.InvalidOperationException'
    : occurred in system.data.dll
    :
    : Additional information: Update requires a valid UpdateCommand
    when passed DataRow collection with modified rows.
    : [/code]
    :
    : Any help would be great because this has been very frustrating to try and figure out. I am kind of new to this so simpler would be better.
    : Oh yeah. I am using OLEDB
    : Thanks alot!
    : James
    : James98765
    : jamesparsons@cox.net
    : http://www.programmersheaven.com/c/Settings/messageboard.htm
    :
    :
    :

    [red]Good luck![/red]
    [blue]Hackman[/blue]

  • : : :
    : : : : : James do me a favor add an item to your project. This item will be a DataForm. When you do it will force you, by way of a data wizard to bound your access database to this form if you choice it as your data source, which you should. It will create a form for you with much of the basic coding routines aready there. You only need to add other coding matters to it. With this process you can look at the way VB2003 does things and it will teach you how to do these things.... You can add to this form what ever you want but it will help you out greatly. Try it, and let me know how it works it will not take long....
    : : : : :
    : : : : :
    : : : : :
    : : : : Sorry to keep bothering you but I think this will be my last question. When I run the DataForm in debug mode and change some things on the DataTable and click update I get the same message that gave me problems in the beginning but this time unstead of breaking the code it gives me the message in an error message. This Message:
    : : : : [code]
    : : : : Additional information: Update requires a valid UpdateCommand when passed DataRow collection with modified rows.
    : : : : [/code]
    : : : : Do you think that this could just be a problem with my computer? My dad who is a programmer, an old one, told me that it is possible that my datatable could be set to read only. Is this possible? and if so how do I fix it
    : : : : Sorry!!!!!!!!!!
    : : : : James
    : : : : James98765
    : : : : jamesparsons@cox.net
    : : : : http://www.programmersheaven.com/c/Settings/messageboard.htm
    : : : :
    : : : :
    : : : What did you change on the table? If you change something that is critical the update information/command may not have that change and thus the error message. When I change something I check all related links and rebuild with new updates command SOoooo what kind of changes did you make....
    : : :
    : : :
    : : :
    : : All I did was change one of the cells(I think thats what you call them) from 2.66 to 2.67. Then I clicked update and got the error message. I am not sure what kind of change you would call that but it didn't seem like it was a durastic change that would do hurt the update command. And this isn't an isolated incident. Anytime I change the text anywhere in the table in any cell and click update I get this error message. I understand if this problem is unsolvable. Thanks alot for your help
    : : James
    : : James98765
    : : jamesparsons@cox.net
    : : http://www.programmersheaven.com/c/Settings/messageboard.htm
    : :
    : :
    : So I see you chose to use a DataGrid instead of Textbox/Single Record method. I thought you wanted Textboxes. But cells in the grid should work just as eaily as the textbox. Hey can I send you something to look at using your email address....
    :
    :
    : I would love that thanks.

    James
    James98765
    jamesparsons@cox.net
    http://www.programmersheaven.com/c/Settings/messageboard.htm

  • : [b][red]This message was edited by HackmanC at 2007-3-22 16:28:13[/red][/b][hr]
    : You need a OleDbCommandBuilder Class.
    :
    : Provides a means of automatically generating single-table commands used to reconcile changes made to a DataSet with the associated database. This class cannot be inherited.
    :
    : The OleDbDataAdapter does not automatically generate the SQL statements required to reconcile changes made to a DataSet with the associated data source. However, you can create an OleDbCommandBuilder object to automatically generate SQL statements for single-table updates if you set the SelectCommand property of the OleDbDataAdapter. Then, any additional SQL statements that you do not set are generated by the OleDbCommandBuilder.
    :
    :
    : [code]
    : Private m_dtGear As New DataTable
    : Private m_daDataAdapter As New OleDb.OleDbDataAdapter
    : m_dtGear.Rows(m_rowPosition)("Field1") = txtFP.Text
    : m_dtGear.Rows(m_rowPosition)("Field2") = txtRPM.Text
    : m_dtGear.Rows(m_rowPosition)("Field3") = txtGR.Text
    : m_dtGear.Rows(m_rowPosition)("Field4") = txtFD.Text
    : m_daDataAdapter = New OleDb.OleDbDataAdapter("Select * FROM Gear", m_cnADONetConnection)
    : [green]Rem YOU HAVE THE SELECT * FROM ... BUT YOU NEED THE UPDATE ... THE DELETE ... ETC.[/green]
    : [red]Dim custCB As OleDbCommandBuilder = New OleDbCommandBuilder (m_daDataAdapter)[/red]
    : m_daDataAdapter.Update(m_dtGear)
    : [/Code]
    :
    : ---------------------------
    : : I am trying to make a program where I have four textboxes that will display text from 4 fields in a Microsoft Access Database. This works so far. I also want to be able to change the text in the text boxes and then click on a save button and have them update the text in the database. This is where I have a problem. Something is wrong with my code but I am not sure what. I am using this code for the update in the click event of the button.
    : : [code]
    : : Private m_dtGear As New DataTable
    : : Private m_daDataAdapter As New OleDb.OleDbDataAdapter
    : : m_dtGear.Rows(m_rowPosition)("Field1") = txtFP.Text
    : : m_dtGear.Rows(m_rowPosition)("Field2") = txtRPM.Text
    : : m_dtGear.Rows(m_rowPosition)("Field3") = txtGR.Text
    : : m_dtGear.Rows(m_rowPosition)("Field4") = txtFD.Text
    : : m_daDataAdapter = New OleDb.OleDbDataAdapter("Select * FROM Gear", m_cnADONetConnection)
    : : m_daDataAdapter.Update(m_dtGear)
    : : [/Code]
    : :
    : : I get this error message during debug mode. When I click the button
    : : [code]
    : : An unhandled exception of type 'System.InvalidOperationException'
    : : occurred in system.data.dll
    : :
    : : Additional information: Update requires a valid UpdateCommand
    : when passed DataRow collection with modified rows.
    : : [/code]
    : :
    : : Any help would be great because this has been very frustrating to try and figure out. I am kind of new to this so simpler would be better.
    : : Oh yeah. I am using OLEDB
    : : Thanks alot!
    : : James
    : : James98765
    : : jamesparsons@cox.net
    : : http://www.programmersheaven.com/c/Settings/messageboard.htm
    : :
    : :
    : :
    :
    : [red]Good luck![/red]
    : [blue]Hackman[/blue]
    :
    :
    Thanks for your suggestion. I forgot to add it in but I already have that line of code in my program. I am starting to think that I just have a problem somewhere else outside of my code. Thanks for your help
    James
    James98765
    jamesparsons@cox.net
    http://www.programmersheaven.com/c/Settings/messageboard.htm

Sign In or Register to comment.

Howdy, Stranger!

It looks like you're new here. If you want to get involved, click one of these buttons!

Categories