I'm having a big issue and hope that anyone here can help me.
I've build a program with vb2010 and use it to add, edit, delete data from databases (mysql and ms access).
Most of the code works, but there is a part that gives me a headache.
With a button click I add/edit records in a database.
But when I click the save changes button (to update the database itself ), I get the following error:
The DataAdapter.SelectCommand property needs to be initialized
The code I have for the save changes button is:
The first rowsAffected is of the mysql (which works perfect). The second rowsAffected2 is for OLEDB and doesn't work. These rowsAffected are used to check if any rows are updated.
Myda = mysql dataapdapter
msda = oledb dataapdater
dsole = mysql dataset
msole = oledb dataset
Any help would be great.
I've build a program with vb2010 and use it to add, edit, delete data from databases (mysql and ms access).
Most of the code works, but there is a part that gives me a headache.
With a button click I add/edit records in a database.
But when I click the save changes button (to update the database itself ), I get the following error:
The DataAdapter.SelectCommand property needs to be initialized
The code I have for the save changes button is:
VB.NET:
Private Sub SongSaveChanges_Click(sender As Object, e As System.EventArgs) Handles SongSaveChanges.Click
'Update song databases (local and online), from the datasets.
If dsOle.HasChanges = False And msOle.HasChanges = False Then
MessageBox.Show("No items need to be saved! This tab will be disabled!")
SongsSwitch.Value = False
Else
Dim cb As MySqlCommandBuilder = New MySqlCommandBuilder(myDa)
Dim cb2 As OleDbCommandBuilder = New OleDbCommandBuilder(msDa)
Dim rowsAffected As Integer = myDa.Update(dsOle, "songs")
Dim rowsAffected2 As Integer = msDa.Update(msOle, "songs")
If rowsAffected = 0 And rowsAffected2 = 0 Then
MessageBox.Show("No records were affected during this save operation!")
SongsSwitch.Value = False
Else
MessageBox.Show(rowsAffected & rowsAffected2 & "row(s) were affected after this save operation!")
SongsSwitch.Value = False
End If
End If
End Sub
The first rowsAffected is of the mysql (which works perfect). The second rowsAffected2 is for OLEDB and doesn't work. These rowsAffected are used to check if any rows are updated.
Myda = mysql dataapdapter
msda = oledb dataapdater
dsole = mysql dataset
msole = oledb dataset
Any help would be great.