The following prodedure should save a new row to the database.
I can't see what the error is, but when I create the command builder, the complier does not like dbsupport.
What have I done wrong
Dim NewRow As System.Data.DataRow
Dim dsadapter As OleDbDataAdapter
Dim dr As DataRow
dr = dssupport.Tables("Supportcall"
.NewRow()
dr("ID"
= txtcallnumber.Text
dr("Customer"
= cmbcustomer.Text
dr("Description"
= txtcalldescription
dr("Contact"
= txtcallcontact.Text
'Get connection string
strconn = "Provider=Microsoft.jet.oledb.4.0;" & "Data Source =P:\Support Calls\mosaic.mdb"
'Build SQL string
insertsql = "INSERT INTO Supportcall(ID, Customer, Description, Contact)" & " VALUES(?,?,?,?)"
'Create new data adpater
dbsupport = New OleDbDataAdapter(insertSQL, strconn)
'Create command builder for adapter
cmbbuild = New OleDbDataAdapter(dbsupport)
'Get Insert command object
dbsupport.InsertCommand = cmbbuild.GetInsertCommand()
'Submit insert statement through adpater
dbsupport.Update(dssupport, "Supportcall"
'Tell data set changes are complete
dssupport.AcceptChanges()
I can't see what the error is, but when I create the command builder, the complier does not like dbsupport.
What have I done wrong
Dim NewRow As System.Data.DataRow
Dim dsadapter As OleDbDataAdapter
Dim dr As DataRow
dr = dssupport.Tables("Supportcall"
dr("ID"
dr("Customer"
dr("Description"
dr("Contact"
'Get connection string
strconn = "Provider=Microsoft.jet.oledb.4.0;" & "Data Source =P:\Support Calls\mosaic.mdb"
'Build SQL string
insertsql = "INSERT INTO Supportcall(ID, Customer, Description, Contact)" & " VALUES(?,?,?,?)"
'Create new data adpater
dbsupport = New OleDbDataAdapter(insertSQL, strconn)
'Create command builder for adapter
cmbbuild = New OleDbDataAdapter(dbsupport)
'Get Insert command object
dbsupport.InsertCommand = cmbbuild.GetInsertCommand()
'Submit insert statement through adpater
dbsupport.Update(dssupport, "Supportcall"
'Tell data set changes are complete
dssupport.AcceptChanges()