|
-
Jan 30th, 2013, 05:47 AM
#1
Thread Starter
New Member
Saving changes from DataGridView to database
Hi,
Just starting with VB 2010. I have a project with (currently) 4 forms - all containing a DataGridView populated from MS Access via a DataAdapter / DataView and working in the same way (just the SQL string changes)
Pseudo-code is thus:
'Open connect (working fine)
'create a data adapter/fill it and create dataview
Dim ds As DataSet
Dim da As System.Data.OleDb.OleDbDataAdapter
Dim dv As DataView
Dim strSQL as string
' create a data adapter
strSQL = "SELECT * FROM Employers"
da = New System.Data.OleDb.OleDbDataAdapter(strSQL, myConnection)
' fill dataset
ds = New DataSet '(strSQL)
da.Fill(ds, strSQL)
dv = New DataView(ds.Tables(0), "EmployerID <>0", "Employer DESC", DataViewRowState.CurrentRows)
EmployerDatGridView.DatSource = dv
'variable are declared at the Form Level, so after making changes / in the form closing event
'update changes
Dim cb As New System.Data.OleDb.OleDbCommandBuilder(da) 'Dont know why I added this (found it somewhere but see I dont use it!)
da.update(ds, "SELECT * FROM Employers")
===> This is working fine in all but one of the forms, but the final line errors
"OleDbException was unhandled by user code - No value given for one of more required parameters.
???????? There is nothing odd about the data in this dataset, the changes I am making are legal , and not constrained at the DB level, so dont understand why it fails, and worse - HAVE NO IDEA HOW TO LOOK FOR WHAT IS WRONG.
Any ideas ? The connection is still OPEN so still linked to the database...
The code may not be great (been looking in various helps and forums), so welcome for any suggestions - but esp why I get this error and how to try and debug it
many thanks, steve
Tags for this Thread
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
|