M
Mark Smith via .NET 247
Hello,
I am adding records to a table using ADO.NET
(I cannot use sql statements e.g. INSERT)
The program through an error on the final update.
The table consists of 3 field:
"A", "B" and "C X"
I am using
- mdac 2.8
- MSDE2000a
Any idea?
Dim DestAdapter As OdbcDataAdapter
Dim DestDS As DataSet
Dim DestDataAdapter As OdbcDataAdapter
Dim DestRow As DataRow
Dim DestTable As DataTable
Dim DestCommBuilder As OdbcCommandBuilder
Dim DestCommand As OdbcCommand
Try
DestDataAdapter = New OdbcDataAdapter("SELECT * FROM [tbltest]", "DSN=ODBC_tbltest;UID=sa;PWD=sa")
DestCommBuilder = New OdbcCommandBuilder(DestDataAdapter)
DestDS = New DataSet
DestDataAdapter.Fill(DestDS, "tbltest")
DestTable = DestDS.Tables("tbltest")
DestRow = DestTable.NewRow()
DestRow("A") = "A,test: " + Now.ToString
DestRow("B") = Now.ToString
DestTable.Rows.Add(DestRow)
DestDataAdapter.Update(DestTable)
MsgBox("Done")
Catch ex As Exception
MsgBox(ex.Message + vbCrLf + ex.Source & vbCrLf & vbCrLf & ex.StackTrace, MsgBoxStyle.Critical, "Error")
End Try
Thanks!
I am adding records to a table using ADO.NET
(I cannot use sql statements e.g. INSERT)
The program through an error on the final update.
The table consists of 3 field:
"A", "B" and "C X"
I am using
- mdac 2.8
- MSDE2000a
Any idea?
Dim DestAdapter As OdbcDataAdapter
Dim DestDS As DataSet
Dim DestDataAdapter As OdbcDataAdapter
Dim DestRow As DataRow
Dim DestTable As DataTable
Dim DestCommBuilder As OdbcCommandBuilder
Dim DestCommand As OdbcCommand
Try
DestDataAdapter = New OdbcDataAdapter("SELECT * FROM [tbltest]", "DSN=ODBC_tbltest;UID=sa;PWD=sa")
DestCommBuilder = New OdbcCommandBuilder(DestDataAdapter)
DestDS = New DataSet
DestDataAdapter.Fill(DestDS, "tbltest")
DestTable = DestDS.Tables("tbltest")
DestRow = DestTable.NewRow()
DestRow("A") = "A,test: " + Now.ToString
DestRow("B") = Now.ToString
DestTable.Rows.Add(DestRow)
DestDataAdapter.Update(DestTable)
MsgBox("Done")
Catch ex As Exception
MsgBox(ex.Message + vbCrLf + ex.Source & vbCrLf & vbCrLf & ex.StackTrace, MsgBoxStyle.Critical, "Error")
End Try
Thanks!