Click to See Complete Forum and Search --> : Procedure - Help!!!!


uni
September 6th, 2001, 10:56 PM
I need to be able to send through a word to a stored procedure in SQL Server which will respond with an associated word. How can you send back a word to a vb app. I imagine you would need to create a field, and add the value to the field. If this is correct, what would the code be?

Thanks in advance.

Cakkie
September 7th, 2001, 01:09 AM
I think you can do it in some other ways.

You can use a command object (ADO) to execute the SQL statement. This allows you to retrieve OUT parameters of the procedure. In this case, you need to set a value to a variable in SQL server, and that variable must be declared as an out parameter.
Your procedure could look like this

CREATE PROC sp_Give_Related_Words
@InWord varchar(10),
@OutWord varchar(10) OUTPUT
as
SELECT @OutWord = RelatedWord FROM Words WHERE Word=@InWord



or

You can give back the value in a recordset, allowing you to return more then one value. Then you just get back a recordset, which can be used on different ways.
In this case, the PROC looks like this

CREATE PROC sp_Give_Related_Words
@InWord varchar(10)
as
SELECT RelatedWord FROM Words WHERE Word=@InWord




Tom Cannaerts
slisse@planetinternet.be

Programming today is a race between software engineers striving to build bigger and better idiot-proof programs, and the universe trying to produce bigger and better idiots. So far, the universe is winning -- Rich Cook

phunkydude
September 7th, 2001, 11:25 AM
I would go with the first proposal of the previous post, just remember to set the command's parameter object's direction property.