-
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
-
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!
-
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
-
By Eoin in forum Database
Replies: 0
Last Post: 08-22-2002, 06:24 AM
-
By VenuGopal Akuthota in forum Database
Replies: 0
Last Post: 02-04-2002, 08:28 AM
-
By Ted Young in forum Database
Replies: 1
Last Post: 08-03-2001, 05:11 PM
-
By Steve in forum Database
Replies: 1
Last Post: 02-09-2001, 01:07 PM
-
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
Forum Rules
|
Top DevX Stories
Easy Web Services with SQL Server 2005 HTTP Endpoints
JavaOne 2005: Java Platform Roadmap Focuses on Ease of Development, Sun Focuses on the "Free" in F.O.S.S.
Wed Yourself to UML with the Power of Associations
Microsoft to Add AJAX Capabilities to ASP.NET
IBM's Cloudscape Versus MySQL
|
Bookmarks