Getting returning values from SQL sentences in VB


DevX Home    Today's Headlines   Articles Archive   Tip Bank   Forums   

Results 1 to 2 of 2

Thread: Getting returning values from SQL sentences in VB

Hybrid View

  1. #1
    Nando Guest

    Getting returning values from SQL sentences in VB


    Hi,
    I'm developing a simple DataBase application which only function is to display
    data, and depending on user interaction it [the application] has to insert
    some values in a Table, And I need the Identity of those records.

    In SQL I simply add this "return @@identity" to the SQL insertion code. The
    point is that due to some requirements on DB this Sql sentences can't be
    store-procedures (yes, all sql sentences are on the VB app it self). And,
    so far, all solutions I've found on the net, to get that value, works for
    stored-procedures.
    What do I do?

    Thanks a lot,
    Nando

  2. #2
    jy Guest

    Re: Getting returning values from SQL sentences in VB


    if you are still going to work against sql server, you can include this statement
    in ado command commandtext:

    eg (using command object aCmd)

    with aCmd
    .activeconnection=<Connection string>
    .commandtext="insert table1(val) values('value 1') return @@identity"
    .commandtype=adCmdText
    .parameters.append .createparameter("return_value", adInteger, adParamReturnValue)

    .execute

    ' use .parameters("return_alue").value
    end with

    "Nando" <xnandox@hotmail.com> wrote:
    >
    >Hi,
    >I'm developing a simple DataBase application which only function is to display
    >data, and depending on user interaction it [the application] has to insert
    >some values in a Table, And I need the Identity of those records.
    >
    >In SQL I simply add this "return @@identity" to the SQL insertion code.

    The
    >point is that due to some requirements on DB this Sql sentences can't be
    >store-procedures (yes, all sql sentences are on the VB app it self). And,
    >so far, all solutions I've found on the net, to get that value, works for
    >stored-procedures.
    >What do I do?
    >
    >Thanks a lot,
    >Nando



Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •  
HTML5 Development Center
 
 
FAQ
Latest Articles
Java
.NET
XML
Database
Enterprise
Questions? Contact us.
C++
Web Development
Wireless
Latest Tips
Open Source


   Development Centers

   -- Android Development Center
   -- Cloud Development Project Center
   -- HTML5 Development Center
   -- Windows Mobile Development Center