Hi all,
I have a really silly problem that i can't find the answer too. I am
working with VB.NET and i am trying to insert a new record into my
access database (pretty easy right?) well i am getting a syntax error
in my SQL statement and nothing i do will correct it. It looks FINE to
me, can anyone help me out??
Thanks so much in advance, here is the code i am using
Dim cn As OleDbConnection
Dim cmd As OleDbCommand
Dim strSQL As String
Dim icount As Integer
Try
cn = New OleDbConnection (constants.CONN ECTIONSTRING)
'provider to be used when working with access database
cn.Open()
cmd = New OleDbCommand
cmd.Connection = cn
cmd.CommandText = "INSERT into original
values(?Name,?P rocessor,?Ram,? HDD,?Monitor,?D evice,?Office,? OS,?Serial)"
cmd.Parameters. Add("?Name", txtName.Text)
cmd.Parameters. Add("?Processor ", txtProc.Text)
cmd.Parameters. Add("?Ram", Me.txtRAM.Text)
cmd.Parameters. Add("?HDD", Me.txthdd.Text)
cmd.Parameters. Add("?Monitor", Me.txtMonitor.T ext)
cmd.Parameters. Add("?Device", Me.txtDevice.Te xt)
cmd.Parameters. Add("?Office", Me.txtOffice.Te xt)
cmd.Parameters. Add("?OS", Me.txtOS.Text)
cmd.Parameters. Add("?Serial", Me.txtserial.Te xt)
icount = cmd.ExecuteNonQ uery
MessageBox.Show (icount)
Catch ex As Exception
MessageBox.Show (ex.Message)
Finally
cn.Close()
End Try
I have a really silly problem that i can't find the answer too. I am
working with VB.NET and i am trying to insert a new record into my
access database (pretty easy right?) well i am getting a syntax error
in my SQL statement and nothing i do will correct it. It looks FINE to
me, can anyone help me out??
Thanks so much in advance, here is the code i am using
Dim cn As OleDbConnection
Dim cmd As OleDbCommand
Dim strSQL As String
Dim icount As Integer
Try
cn = New OleDbConnection (constants.CONN ECTIONSTRING)
'provider to be used when working with access database
cn.Open()
cmd = New OleDbCommand
cmd.Connection = cn
cmd.CommandText = "INSERT into original
values(?Name,?P rocessor,?Ram,? HDD,?Monitor,?D evice,?Office,? OS,?Serial)"
cmd.Parameters. Add("?Name", txtName.Text)
cmd.Parameters. Add("?Processor ", txtProc.Text)
cmd.Parameters. Add("?Ram", Me.txtRAM.Text)
cmd.Parameters. Add("?HDD", Me.txthdd.Text)
cmd.Parameters. Add("?Monitor", Me.txtMonitor.T ext)
cmd.Parameters. Add("?Device", Me.txtDevice.Te xt)
cmd.Parameters. Add("?Office", Me.txtOffice.Te xt)
cmd.Parameters. Add("?OS", Me.txtOS.Text)
cmd.Parameters. Add("?Serial", Me.txtserial.Te xt)
icount = cmd.ExecuteNonQ uery
MessageBox.Show (icount)
Catch ex As Exception
MessageBox.Show (ex.Message)
Finally
cn.Close()
End Try
Comment