CodeGuru Home VC++ / MFC / C++ .NET / C# Visual Basic VB Forums Developer.com
Results 1 to 3 of 3
  1. #1
    Join Date
    Sep 2000
    Posts
    58

    Procedure - Help!!!!

    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.


  2. #2
    Join Date
    Jan 2000
    Location
    Olen, Belgium
    Posts
    2,477

    Re: Procedure - Help!!!!

    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
    [email protected]

    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
    Tom Cannaerts
    email: [email protected]
    www.tom.be (dutch site)

  3. #3
    Join Date
    Aug 2000
    Location
    Namibia
    Posts
    139

    Re: Procedure - Help!!!!

    I would go with the first proposal of the previous post, just remember to set the command's parameter object's direction property.


Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •  





Click Here to Expand Forum to Full Width

Featured