Inserting, deleting and editing rows in an Access database
Posted on 2006-06-16
I am new to VB.net and have become stuck trying to insert, delete and edit a dataset.
I can connect and read the data and bind it to a datagrid, but cannot get it to update.
Here is my code:
Dim da As New OleDbDataAdapter
Dim dbCommand As New OleDbCommand
Dim dt As New DataTable
Dim dr As DataRow
dbConnection.ConnectionString = "Provider = Microsoft.Jet.OLEDB.4.0;Data Source=c:\test.mdb"
Catch ex As Exception
MsgBox("Cannot open Database" & vbCr & ex.Message, MsgBoxStyle.Critical, "Error!")
Dim SQLStr As String
SQLStr = "select * from driver"
dbCommand.Connection = dbConnection
dbCommand.CommandType = CommandType.Text
dbCommand.CommandText = SQLStr
da.SelectCommand = dbCommand
grdShift.DataSource = dt
dr = dt.NewRow
dr("driverNo") = "xyz"
dr("driverName") = "1234567"