Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations Chriss Miller on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

how to run a procedures?

Status
Not open for further replies.

luisve

Programmer
Jun 24, 2005
29
US
hi i have a procedure call insert i can run it from the server explorer, how can i call it using code if it have two variables(id, and fln)? thanks for the help
 
something like this. untested.
I have to presume some things
1. You use sqlserver
2. you want have some data returned
3. you want to have them in a datatable
4. the variablenames are @id and @fln
5. the stored procedure name
6. the values of the variables
7. ...

Code:
dim c as new sqlconnection
dim d as new sqldataadapter
dim co as new sqlcommand
dim dt as new datatable
c.connectionstring = ...
c.open
co.connection = c
co.commandtype = storedprocedure
co.commandtext = "storedprocedurename"
co.parameters.add("@id",sqldbtype.int).value = 1
co.parameters.add("@fln",sqldbtype.varchar,50).value = "valuehere"
d.selectcommand = co
d.fill(dt)
d.fillschema(dt,source)



Christiaan Baes
Belgium

If you want to get an answer read this FAQ faq796-2540
There's no such thing as a winnable war - Sting
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top