I am working on a project for my final in vb.net and I have a weird error when I try to insert info into my database. When I run the application it errors out on command.ExecuteNonQuery()and the error is Syntax error in INSERT INTO statement.
I have the fields in my database are set as text at 255 chars. I have both inmports statments at the top, and as far as I can tell my statement is right.
Here is my code.
Dim con As New OleDbConnection("Provider=Microsoft.ACE.OLEDB.12.0;Data Source =../../Base/LogTextCopy.accdb;Persist Security Info=False;")
Dim StrSQL As String = "INSERT INTO TIMEANDDATE(DATE, TIME) values(@date, @time)"
Dim command As New OleDbCommand()
command.CommandText = StrSQL
command.Connection = con
command.Parameters.Clear()
Dim ParameterDate As New OleDbParameter
ParameterDate.ParameterName = "@date"
ParameterDate.OleDbType = OleDbType.Char
ParameterDate.Size = 100
ParameterDate.Direction = ParameterDirection.Input
ParameterDate.Value = strDate
Dim ParameterTime As New OleDbParameter
ParameterTime.ParameterName = "@time"
ParameterTime.OleDbType = OleDbType.Char
ParameterTime.Size = 100
ParameterTime.Direction = ParameterDirection.Input
ParameterTime.Value = strTime
command.Parameters.Add(ParameterDate)
command.Parameters.Add(ParameterTime)
con.Open()
command.ExecuteNonQuery()
con.Close()
DataBaseUpdate()

New Topic/Question
Reply




MultiQuote








|