I am attempring to write an insert statement to add records to an access database table. I do not want to define the values that will be added to the database in the query and wish to use parameters. I am a little confused as to how to do this:
So far I have got:
Dim addsoft AsString = " Insert INTO [GKLS Software] " & _
" ([GKLS Software].Application, [GKLS Software].VendorID, [GKLS Software].SoftwareTypeID, " & _
" [GKLS Software].Product_Key, [GKLS Software].Comments) " & _
" VALUES (?,?,?,?,?) "
Is this correct or is the following correct?
Dim addsoft AsString = " Insert INTO [GKLS Software] " & _
" ([GKLS Software].Application, [GKLS Software].VendorID, [GKLS Software].SoftwareTypeID, " & _
" [GKLS Software].Product_Key, [GKLS Software].Comments) " & _
" VALUES (@app,@vendId, @softtype, @prodkey,@comms) "
What i understood was that the first way is for oledb and the second for sqlserver.
Also, after the insert statement is defined, how do i pass the parameters to the statement. I know that for the second method its something like:
objcommand1.Parameters.Add("@app, txtapplication.Text)
objcommand1.Parameters.Add("@vendId, ddlvendors.selecteditem)
blah blah
however, if i have to use the first method how to i do this since each parameter is defined by a question-mark.
Please could someone kindly help.
Thanks in advance!
So far I have got:
Dim addsoft AsString = " Insert INTO [GKLS Software] " & _
" ([GKLS Software].Application, [GKLS Software].VendorID, [GKLS Software].SoftwareTypeID, " & _
" [GKLS Software].Product_Key, [GKLS Software].Comments) " & _
" VALUES (?,?,?,?,?) "
Is this correct or is the following correct?
Dim addsoft AsString = " Insert INTO [GKLS Software] " & _
" ([GKLS Software].Application, [GKLS Software].VendorID, [GKLS Software].SoftwareTypeID, " & _
" [GKLS Software].Product_Key, [GKLS Software].Comments) " & _
" VALUES (@app,@vendId, @softtype, @prodkey,@comms) "
What i understood was that the first way is for oledb and the second for sqlserver.
Also, after the insert statement is defined, how do i pass the parameters to the statement. I know that for the second method its something like:
objcommand1.Parameters.Add("@app, txtapplication.Text)
objcommand1.Parameters.Add("@vendId, ddlvendors.selecteditem)
blah blah
however, if i have to use the first method how to i do this since each parameter is defined by a question-mark.
Please could someone kindly help.
Thanks in advance!