|
-
Jun 9th, 2002, 05:29 PM
#1
Thread Starter
Junior Member
Saving a new row to the database
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()
-
Jun 10th, 2002, 03:26 AM
#2
Addicted Member
You are referencing dssupport before you are creating an instance of it - which you do later in your code. Also you need to put your code in a try-catch-end try block. This will enable you to debug your code more efficiently and gives you error messages in your autos window
Wind and waves resolves all problems.
-
Jun 11th, 2002, 10:25 PM
#3
Thread Starter
Junior Member
Where do I do that then?
How should I reorganise the code then
Posting Permissions
- You may not post new threads
- You may not post replies
- You may not post attachments
- You may not edit your posts
-
Forum Rules
|
Click Here to Expand Forum to Full Width
|