I am sure someone must have posted an answer on this but I cant find it. Just starting using VB2010 so on a steep learning curve, but finally making the leap from easy VB6 !
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). NOTE - although some of the stuff below seems to work, I strongly suspect I am not doing this the right way, so would appreciate a pointer towards what I should be doing
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
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
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). NOTE - although some of the stuff below seems to work, I strongly suspect I am not doing this the right way, so would appreciate a pointer towards what I should be doing
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
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