Replacing stored procedure

  • Thread starter Thread starter John
  • Start date Start date
J

John

Hi

I need to insert a new record in an access table with values for various
fields provided. In sql server you have an insert stored procedure to which
you pass the field values as parameters. How do you do something like this
in access using oledb & vb.net? Whatever is easiest.

Thanks

Regards
 
In OleDb, you can write your query like so:

INSERT INTO TableName VALUES (?,?,?,?)

and attach params in order, if you want params. Access queries are also
possible to use like a stored proc. I have not worked with Access enough to
validate this method, however.

--
Gregory A. Beamer
MVP; MCP: +I, SE, SD, DBA

************************************************
Think Outside the Box!
************************************************
 
It's essentially the same, you just use a Paramaterized sql statement (in
oledb it's ? instead or "@VariableName"). So you'll have an insert command,
update command, delete command and select command - for the first three
you'll declare the params the same way you do with a Stored proc specifying
the column mapping so the adapter will know what to pass to what field.

--

W.G. Ryan, eMVP

Have an opinion on the effectiveness of Microsoft Embedded newsgroups?
Let Microsoft know!
https://www.windowsembeddedeval.com/community/newsgroups
 
Thanks. Can a see a simple example of this somewhere just to get my head
round it fully?

Thanks

Regards
 
Let's say if I have values 123, "ABC", "01/01/1990", how would I insert them
into a record in an access table?

Thanks

Regards
 
dataAdapter.UpdateCommand = "Insert Into myTable Values(?,?,?)"

then you'd add the params to the parameter collection. It's a bit long to
write out but the easy way to get it is to just drag a OleDbDataAdapter onto
your form, configure it for a SELECT statement to the table you are
interested in, and as long as it has a PK it should generate all the logic
for you. You an get a feel for what it all looks like form there.

--

W.G. Ryan, eMVP

Have an opinion on the effectiveness of Microsoft Embedded newsgroups?
Let Microsoft know!
https://www.windowsembeddedeval.com/community/newsgroups
 
Back
Top