Help!
I'm using VisualStudio.NET Academic. I'm only using VB.NET for now and I'm having trouble with the .Parameter.Add method. The Academic version does not include the Microsoft DB OLE Provider for Oracle driver, but I can successfully insert data if I hard code the values. The big problem is get VB to recognise that the placeholder '@in_name". Here's the code:
Dim cmd As OleDbCommand
conn.Open()
' this works?
cmd = New OleDBCommand("INSERT INTO testtable (c1, ta_name, ta_number)" & _
" VALUES('test4', 'Mike', 569)", conn)
' this fails because the value held by @in_name is not recognised
'cmd = New OleDbCommand("INSERT INTO testtable (c1, ta_name, ta_number)" & _
" VALUES('test4', @in_name, 569)", conn)
'cmd.Parameters.Add("@in_name", OleDbType.VarChar, 10, txtName.Text)
Try
cmd.ExecuteNonQuery()
MessageBox.Show("Row Inserted!")
Catch SQLExceptionErr As Exception
MessageBox.Show(SQLExceptionErr.Message)
End Try
conn.Close()
How do I get VB.NET to recognize the placeholder.
Thanks
Mike Parish
I'm using VisualStudio.NET Academic. I'm only using VB.NET for now and I'm having trouble with the .Parameter.Add method. The Academic version does not include the Microsoft DB OLE Provider for Oracle driver, but I can successfully insert data if I hard code the values. The big problem is get VB to recognise that the placeholder '@in_name". Here's the code:
Dim cmd As OleDbCommand
conn.Open()
' this works?
cmd = New OleDBCommand("INSERT INTO testtable (c1, ta_name, ta_number)" & _
" VALUES('test4', 'Mike', 569)", conn)
' this fails because the value held by @in_name is not recognised
'cmd = New OleDbCommand("INSERT INTO testtable (c1, ta_name, ta_number)" & _
" VALUES('test4', @in_name, 569)", conn)
'cmd.Parameters.Add("@in_name", OleDbType.VarChar, 10, txtName.Text)
Try
cmd.ExecuteNonQuery()
MessageBox.Show("Row Inserted!")
Catch SQLExceptionErr As Exception
MessageBox.Show(SQLExceptionErr.Message)
End Try
conn.Close()
How do I get VB.NET to recognize the placeholder.
Thanks
Mike Parish