|
-
Nov 6th, 2009, 07:57 AM
#1
Thread Starter
Fanatic Member
[RESOLVED] Update problem
OleDbException Unhandled
I can't figure out why.
Code:
Private cnxnString As String = ("Provider=Microsoft.Jet.OLEDB.4.0;Data Source=F:\VDM\AIDS Action Committee\AAC047\AAC047.MDB")
Private cnxn As New System.Data.OleDb.OleDbConnection(cnxnString)
Private DataAdapter As New System.Data.OleDb.OleDbDataAdapter("SELECT * FROM [COMBINED NCOA]", cnxn)
Private CommandBuilder As New System.Data.OleDb.OleDbCommandBuilder(DataAdapter)
Private Table As New DataTable
Private Sub ButtonCheckDigit_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles ButtonCheckDigit.Click
DataAdapter.Fill(Table)
DataAdapter.UpdateCommand = CommandBuilder.GetUpdateCommand
DataAdapter.MissingSchemaAction = MissingSchemaAction.AddWithKey
For Each row As DataRow In Table.Rows
row("TEST") = "XXX"
DataAdapter.Update(Table)
Next
MsgBox("Done")
End Sub
-
Nov 6th, 2009, 08:27 AM
#2
Re: Update problem
First up, you don't call Update after each change. You change the lot and then call Update once.
As for the error, perhaps ab bit of information about the error, which the IDE has provided to you to help you diagnose the problem, could be provided to us to help us diagnose the problem. That said, setting MissingSchemaAction after calling Fill is of no use, so that might be a problem. Your setting of the UpdateCommand is also of no use.
-
Nov 6th, 2009, 08:33 AM
#3
Thread Starter
Fanatic Member
Re: Update problem
When i wrap the code into a try catch the exception is: No value given for one or more required parameters.
i deleted the setting of the update command
i moved the MissingSchemaAction to before calling the fill
i moved the DataAdapter Update after the For Each loop
still the same exception. i think i'm going crazy. i feel like i've done this a hundred times before without any problems. not a good morning.
-
Nov 6th, 2009, 08:37 AM
#4
Re: Update problem
There is a generic list of things to check for that error in the article What does this error mean, and how do I fix it? from our Database Development FAQs/Tutorials
I suspect the issue in this case is that one of your field names is a reserved word (or similar).
-
Nov 6th, 2009, 08:51 AM
#5
Thread Starter
Fanatic Member
Re: Update problem
OK. i figured it out. At first i thought my field name "test" was a reserved word. I changed the name but still got the same error. then i changed the name of my table from "combined ncoa" to "combinedncoa" and it worked even with a field name of "test". so it did not like the space in the table name.
Posting Permissions
- You may not post new threads
- You may not post replies
- You may not post attachments
- You may not edit your posts
-
Forum Rules
|
Click Here to Expand Forum to Full Width
|