[RESOLVED] Update to an Access DB
I'm using OleDbDataAdapter1, OleDbConnection1, DataSet11.
So why doesn't this code work:
Code:
Public Function CreateCmdsAndUpdate(ByVal DataSet11 As DataSet, ByVal myConnection As String, ByVal mySelectQuery As String, ByVal Bathroom As String) As DataSet
Dim myConn As New OleDbConnection1(myConnection)
Dim myDataAdapter As New OleDbDataAdapter()
myDataAdapter.SelectCommand = New OleDbCommand(mySelectQuery, myConn)
Dim custCB As OleDbCommandBuilder = New OleDbCommandBuilder(myDataAdapter)
myConn.Open()
Dim DataSet1 As DataSet = New DataSet()
myDataAdapter.Fill(DataSet11)
myDataAdapter.Update(DataSet11, Bathroom)
myConn.Close()
Return DataSet11
End Function
Thank you,
Pierre
Re: Update to an Access DB
I made a few change to your code. If it doesn't help, are you getting a specific error with that code? How do you know it's not working?
VB Code:
Public Function CreateCmdsAndUpdate(ByVal DataSet11 As DataSet, ByVal myConnection As String, ByVal mySelectQuery As String, ByVal Bathroom As String) As DataSet
Dim myConn As New OleDbConnection(myConnection)
Dim myDataAdapter As New OleDbDataAdapter(mySelectQuery, myConn)
'myDataAdapter.SelectCommand = New OleDbCommand(mySelectQuery, myConn)
'Dim custCB As OleDbCommandBuilder = New OleDbCommandBuilder(myDataAdapter)
myConn.Open()
Dim DataSet1 As DataSet = New DataSet
myDataAdapter.Fill(DataSet11, Bathroom)
'myDataAdapter.Update(DataSet11, Bathroom)
myConn.Close()
Return DataSet11
End Function
Re: Update to an Access DB
I'm afraid that your code doesn't make a lot of sense. Your method is named "CreateCmdsAndUpdate", which implies that you want to save the changes from an existing DataTable. Then you proceed to create a DataSet that you never use and retrieve data from the database. Finally you return the very same DataSet that you passed in.
Please explain what the purpose of the method is. We can't tell you exactly what's wrong if we don't know what right is. Please take a little more time when posting and provide all the relevant information.