Click to See Complete Forum and Search --> : Stored procedures


jemis7
February 10th, 2000, 10:26 AM
I have been writing a program with lots of sql queris and I would like to know how to write stored procedures in Visual Basic coding. I need this very very much.
Can you please tell me how to write, where to store it and how to execute ?
Also,I've heard that parameters can be passed to a stored procedure...
Of course,I need to write some very complicated procedures...
An example would be much appreciated...
Thnx

February 10th, 2000, 10:41 AM
In SQL Server 6.5 you can do the following.
To create a stored procedure go to the database you want and then goto manage stored procedures.
create a procedure like the following
CREATE PROCEDURE sp_mytableSelect @id numeric(10,0)AS
select * from mytable where id=@id

Then when you want to call it from vb do it the same way as you would do any SQL statement and pass the id parameter to it.
ie

SqlStr = "sp_mytableSelect " & RequiredId
set ars=cnn.execute(SqlStr)



this will run the stored procedure and return any value received into the recordset.
This is simplistic but I hope it gives you a start.