J
johnBoy
I am new to vb.net and I am trying to add a row of data to an access database.
But I am getting this error above when it gets to the dataAdaptor fill line
of code.
The table and datbase exist and are spelt correctly.
Please has anyone any ideas. Code is below:
Code:
Dim myDataSet As New DataSet()
Try
Dim myOleDbConnection As OleDbConnection
myOleDbConnection = New
OleDb.OleDbConnection("Provider=Microsoft.Jet.OLEDB.4.0;" & _
"Data Source=R:\rrep\pid\DataSht.mdb;")
myOleDbConnection.Open()
Dim myOleDbDataAdapter As OleDbDataAdapter
myOleDbDataAdapter = New OleDbDataAdapter("select *
from tbjg", myOleDbConnection)
Dim ditem_tag As New DataColumnMapping("item_tag", "item_tag")
Dim ddtemp As New DataColumnMapping("temp", "temp")
Dim ddpress As New DataColumnMapping("press", "press")
myOleDbDataAdapter.Fill(myDataSet, "Articles")
Dim rowArticle As DataRow = myDataSet.Tables(0).NewRow()
rowArticle("item_tag") = "1100-B-222"
rowArticle("temp") = "250"
rowArticle("press") = "15"
myDataSet.Tables(0).Rows.Add(rowArticle)
myOleDbDataAdapter.Update(myDataSet, "Articles")
myDataSet.Tables("Articles").AcceptChanges()
Catch ex As OleDbException
' Reject DataSet changes
MessageBox.Show(ex.Message)
End Try
But I am getting this error above when it gets to the dataAdaptor fill line
of code.
The table and datbase exist and are spelt correctly.
Please has anyone any ideas. Code is below:
Code:
Dim myDataSet As New DataSet()
Try
Dim myOleDbConnection As OleDbConnection
myOleDbConnection = New
OleDb.OleDbConnection("Provider=Microsoft.Jet.OLEDB.4.0;" & _
"Data Source=R:\rrep\pid\DataSht.mdb;")
myOleDbConnection.Open()
Dim myOleDbDataAdapter As OleDbDataAdapter
myOleDbDataAdapter = New OleDbDataAdapter("select *
from tbjg", myOleDbConnection)
Dim ditem_tag As New DataColumnMapping("item_tag", "item_tag")
Dim ddtemp As New DataColumnMapping("temp", "temp")
Dim ddpress As New DataColumnMapping("press", "press")
myOleDbDataAdapter.Fill(myDataSet, "Articles")
Dim rowArticle As DataRow = myDataSet.Tables(0).NewRow()
rowArticle("item_tag") = "1100-B-222"
rowArticle("temp") = "250"
rowArticle("press") = "15"
myDataSet.Tables(0).Rows.Add(rowArticle)
myOleDbDataAdapter.Update(myDataSet, "Articles")
myDataSet.Tables("Articles").AcceptChanges()
Catch ex As OleDbException
' Reject DataSet changes
MessageBox.Show(ex.Message)
End Try