E
erin.sebastian
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.CONNECTIONSTRING)
'provider to be used when working with access database
cn.Open()
cmd = New OleDbCommand
cmd.Connection = cn
cmd.CommandText = "INSERT into original
values(?Name,?Processor,?Ram,?HDD,?Monitor,?Device,?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.Text)
cmd.Parameters.Add("?Device", Me.txtDevice.Text)
cmd.Parameters.Add("?Office", Me.txtOffice.Text)
cmd.Parameters.Add("?OS", Me.txtOS.Text)
cmd.Parameters.Add("?Serial", Me.txtserial.Text)
icount = cmd.ExecuteNonQuery
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.CONNECTIONSTRING)
'provider to be used when working with access database
cn.Open()
cmd = New OleDbCommand
cmd.Connection = cn
cmd.CommandText = "INSERT into original
values(?Name,?Processor,?Ram,?HDD,?Monitor,?Device,?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.Text)
cmd.Parameters.Add("?Device", Me.txtDevice.Text)
cmd.Parameters.Add("?Office", Me.txtOffice.Text)
cmd.Parameters.Add("?OS", Me.txtOS.Text)
cmd.Parameters.Add("?Serial", Me.txtserial.Text)
icount = cmd.ExecuteNonQuery
MessageBox.Show(icount)
Catch ex As Exception
MessageBox.Show(ex.Message)
Finally
cn.Close()
End Try