P
Paul#
I am trying to update an access database.
I have been able to perform the following:
1) open db
2) create dataset from db
3) modify dataset
my troubles lie in:
4) updating the access database with the new dataset
It gives me an exception from system.data.oledbexception.
'my function call is:
'***********************************************************************
CreateCmdsAndUpdate("Provider=Microsoft.Jet.OLEDB.4.0;" & _
"Password=""""; User ID=Admin;" & _
"Data Source=" & strpathname, "SELECT AXHTP FROM Cst_all",
"Table", _
"UPDATE Cst_all")
'my function is:
'************************************************************************
Public Function CreateCmdsAndUpdate(ByVal myConnection As String,
ByVal mySelectQuery As String, ByVal myTableName As String, ByVal
myUpdateQuery As String) As DataSet
Dim myConn As New OleDbConnection(myConnection)
Dim myDataAdapter As New OleDbDataAdapter
Dim oCommandbuilder As New SqlClient.SqlCommandBuilder
myDataAdapter.SelectCommand = New OleDbCommand(mySelectQuery,
myConn)
myDataAdapter.UpdateCommand = New OleDbCommand(myUpdateQuery,
myConn)
myConn.Open()
Dim custDS As DataSet = New DataSet
Dim currentrow As DataRow
myDataAdapter.Fill(custDS)
For Each currentrow In custDS.Tables(myTableName).Rows
currentrow.Item(0) =
currentrow.Item(0).ToString.Replace("A", " ")
Next
DataGrid.DataSource = custDS
myDataAdapter.Update(custDS, myTableName) 'error occurs here
myConn.Close()
Return custDS
End Function
'*************************************************************************
Thanks for your help,
Paul#
I have been able to perform the following:
1) open db
2) create dataset from db
3) modify dataset
my troubles lie in:
4) updating the access database with the new dataset
It gives me an exception from system.data.oledbexception.
'my function call is:
'***********************************************************************
CreateCmdsAndUpdate("Provider=Microsoft.Jet.OLEDB.4.0;" & _
"Password=""""; User ID=Admin;" & _
"Data Source=" & strpathname, "SELECT AXHTP FROM Cst_all",
"Table", _
"UPDATE Cst_all")
'my function is:
'************************************************************************
Public Function CreateCmdsAndUpdate(ByVal myConnection As String,
ByVal mySelectQuery As String, ByVal myTableName As String, ByVal
myUpdateQuery As String) As DataSet
Dim myConn As New OleDbConnection(myConnection)
Dim myDataAdapter As New OleDbDataAdapter
Dim oCommandbuilder As New SqlClient.SqlCommandBuilder
myDataAdapter.SelectCommand = New OleDbCommand(mySelectQuery,
myConn)
myDataAdapter.UpdateCommand = New OleDbCommand(myUpdateQuery,
myConn)
myConn.Open()
Dim custDS As DataSet = New DataSet
Dim currentrow As DataRow
myDataAdapter.Fill(custDS)
For Each currentrow In custDS.Tables(myTableName).Rows
currentrow.Item(0) =
currentrow.Item(0).ToString.Replace("A", " ")
Next
DataGrid.DataSource = custDS
myDataAdapter.Update(custDS, myTableName) 'error occurs here
myConn.Close()
Return custDS
End Function
'*************************************************************************
Thanks for your help,
Paul#