I am trying to get this to run an insert into the database. I keep getting an error saying that it is missing a ;. I don't really get where that would go.
Any one?
The actual method works in other places of the application so it must be a syntax problem.
Any one?
The actual method works in other places of the application so it must be a syntax problem.
VB.NET:
' Creates the OleDb connection
Dim connect As New OleDb.OleDbConnection
connect.ConnectionString = "PROVIDER=Microsoft.Jet.OLEDB.4.0;Data Source = C:\Holiday.mdb"
'Creates a variable to store the sql ? says look for the value in the parameter
'Always specify the field names that you want the data to be entered into
Dim sql As String = "INSERT INTO tblbooking (totalcost) VALUES (?) WHERE [BookingID] =" & booking
'Creates a variable command so that the sql and connection variables are run
Dim command As New System.Data.OleDb.OleDbCommand(sql, connect)
'insted of using a concat use the param value
command.Parameters.AddWithValue("@totalcost", runningtotalofbooking)
'opens connection
connect.Open()
'runs the command variable
command.ExecuteNonQuery()
'closes connection
connect.Close()