OleDbDataAdapter Update
-
I am new to ASP.NET and ADO.NET and I am having some problems with the following code so I was hoping that someone would be able to help me. When I run the page that contains this code I get this error:
Update requires a valid UpdateCommand when passed DataRow collection with modified rows. Description: An unhandled exception occurred during the execution of the current web request. Please review the stack trace for more information about the error and where it originated in the code. Exception Details: System.InvalidOperationException: Update requires a valid UpdateCommand when passed DataRow collection with modified rows. Source Error: Line 36: next i Line 37: Line 38: oDataAdapt.Update( dsDataSet ) Line 39: Line 40: End Sub
I have looked at the Update method of OleDbDataAdapter class but I cannot seem to pinpoint the problem. Am I missing some function that must be ran before I run Update?Dim logConn As OleDbConnection
Dim oDataAdapt As OleDbDataAdapter
Dim dsDataSet As New DataSet'the connection string is here somewhere
Dim strSQL As String
strSQL = "SELECT * FROM tblPracticum WHERE PlacementNo = " & Session("PlacementNo")
oDataAdapt = New OleDbDataAdapter( strSQL, logConn )
oDataAdapt.Fill( dsDataSet )'Populate the fields with the record information that was pulled from the dbase
Dim i As Integer
For i = 1 to 5
dsDataSet.Tables.Item(0).Rows(0).Item("txtBox" & i) = Session("txtBox" & i )
next i
oDataAdapt.Update( dsDataSet )// Afterall, I realized that even my comment lines have bugs
-
I am new to ASP.NET and ADO.NET and I am having some problems with the following code so I was hoping that someone would be able to help me. When I run the page that contains this code I get this error:
Update requires a valid UpdateCommand when passed DataRow collection with modified rows. Description: An unhandled exception occurred during the execution of the current web request. Please review the stack trace for more information about the error and where it originated in the code. Exception Details: System.InvalidOperationException: Update requires a valid UpdateCommand when passed DataRow collection with modified rows. Source Error: Line 36: next i Line 37: Line 38: oDataAdapt.Update( dsDataSet ) Line 39: Line 40: End Sub
I have looked at the Update method of OleDbDataAdapter class but I cannot seem to pinpoint the problem. Am I missing some function that must be ran before I run Update?Dim logConn As OleDbConnection
Dim oDataAdapt As OleDbDataAdapter
Dim dsDataSet As New DataSet'the connection string is here somewhere
Dim strSQL As String
strSQL = "SELECT * FROM tblPracticum WHERE PlacementNo = " & Session("PlacementNo")
oDataAdapt = New OleDbDataAdapter( strSQL, logConn )
oDataAdapt.Fill( dsDataSet )'Populate the fields with the record information that was pulled from the dbase
Dim i As Integer
For i = 1 to 5
dsDataSet.Tables.Item(0).Rows(0).Item("txtBox" & i) = Session("txtBox" & i )
next i
oDataAdapt.Update( dsDataSet )// Afterall, I realized that even my comment lines have bugs
-
Hi there, You need to specify a valid
UpdateCommand
for the adapter object, for more information see: Updating the Database with a DataAdapter and the DataSet[^]Thank you for your reply minhpc_bk. I was able to find the article that you listed but now I have another problem about the database not being updatable or something like that. I am looking into different articles but so far I've had no luck. In any case, thank you for taking the time to respond. I really appreciate it. // Afterall, I realized that even my comment lines have bugs
-
Thank you for your reply minhpc_bk. I was able to find the article that you listed but now I have another problem about the database not being updatable or something like that. I am looking into different articles but so far I've had no luck. In any case, thank you for taking the time to respond. I really appreciate it. // Afterall, I realized that even my comment lines have bugs
Hi Toni, Which database are you using? I guess it's Access, right? If so, you need to grant the ASP.NET worker process identity(it's normally the ASPNET account) the write permission to the db file. You might want to check out the KB [Process and request identity in ASP.NET](http://support.microsoft.com/default.aspx?scid=KB;EN-US;q317012c)[[^](http://support.microsoft.com/default.aspx?scid=KB;EN-US;q317012c "New Window")] for more information.