What's the best way to call a Stored Procedure from VB6?


DevX Home    Today's Headlines   Articles Archive   Tip Bank   Forums   

Results 1 to 3 of 3

Thread: What's the best way to call a Stored Procedure from VB6?

  1. #1
    Join Date
    Mar 2005
    Location
    Brazil - Campinas - SP
    Posts
    40

    What's the best way to call a Stored Procedure from VB6?

    Hi, I have in my SQLServer 2000 the following Stored Procedure...
    ---------------------------------------------------------------
    CREATE PROCEDURE sp_idGeraNf_CriaNf
    @CnpjOrigem Varchar(50),
    @codTipoNf Bigint,
    @ValorTotalNf Money,

    @codNf Bigint OUTPUT AS

    BEGIN
    INSERT INTO tbLekkus_PedidoVendaNF
    (CnpjOrigem,
    codTipoNf,
    ValorTotalNf)
    VALUES
    (@CnpjOrigem,
    @codTipoNf,
    @ValorTotalNf)
    SELECT @codNf=@@Identity
    END
    --------------------------------------------------------------------

    ...to add data on database using this SP, I use the following code source...

    *****************************************************
    Set par = cmd.CreateParameter("CnpjOrigem", adVarChar, adParamInput, 50)
    cmd.Parameters.Append par
    cmd.Parameters(0) = sCnpjOrigem

    Set par = cmd.CreateParameter("codTipoNf", adBigInt, adParamInput)
    cmd.Parameters.Append par
    cmd.Parameters(1) = 44

    Set par = cmd.CreateParameter("ValorTotalNf", adCurrency, adParamInput)
    cmd.Parameters.Append par
    cmd.Parameters(2) = 55.65

    Set par = cmd.CreateParameter("codNf", adBigInt, adParamOutput)
    cmd.Parameters.Append par

    cmd.ActiveConnection = gblCn
    cmd.Execute

    ' Set rConsulta = cmd.Execute

    MyNumberKey=cmd.Parameters.Item(3)

    *****************************************************
    ...it's working fine, but now, I need call a Stored Procedure with 98 fields, in the way that I'm following I'll need create about 300 lines of code considering
    the following code to each field that I'll need populate...
    ..."Set par = cmd.CreateParameter("codTipoNf", adBigInt, adParamInput)
    cmd.Parameters.Append par
    cmd.Parameters(1) = 44".

    Anyone can help me?
    There are other ways to me insert the data to a database from this SP ?

    Since now, thank very much
    best regard
    Biruel

  2. #2
    Join Date
    Nov 2003
    Location
    Portland, OR
    Posts
    8,387
    I don't know of any shortcut to pass 98 parameters to a stored procedure. I would probably use one of the many code generators available to generate the code automatically: http://www.google.com/search?q=ado+s...dure+generator
    Phil Weber
    http://www.philweber.com

    Please post questions to the forums, where others may benefit.
    I do not offer free assistance by e-mail. Thank you!

  3. #3
    Join Date
    Mar 2005
    Location
    Brazil - Campinas - SP
    Posts
    40
    Thank very much Phis, this Add-In
    http://www.vbrad.com/article.aspx?id=103 help me a lot.

    big hug
    biruel (skype: ricardobiruel)

Similar Threads

  1. Replies: 0
    Last Post: 08-22-2002, 06:24 AM
  2. Replies: 0
    Last Post: 02-04-2002, 08:28 AM
  3. Replies: 1
    Last Post: 08-03-2001, 05:11 PM
  4. Replies: 1
    Last Post: 02-09-2001, 01:07 PM
  5. NetUserEnum Api
    By Mike in forum VB Classic
    Replies: 2
    Last Post: 04-24-2000, 03:30 PM

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