Solved

How to call a sql server procedure from within vb6?

Posted on 2008-10-27
4
220 Views
Last Modified: 2010-05-03
Hello,

Can somebody give me an example how to call a function or procedure in sql server from within vb6 using ADO?

Regards,
Dennis
0
Comment
Question by:Schuttend
  • 2
4 Comments
 
LVL 6

Expert Comment

by:openshac
ID: 22811279

' Set up a command object for the stored procedure.
With ADOcmd
    .ActiveConnection = conProdDB
    .CommandText = "myProcName"
    .CommandType = adCmdStoredProc
 
' Set up input parameters.  
    .Parameters.Append .CreateParameter("@MyParam", adInteger, adParamInput, , 40027)
 
' Execute command
    .Execute
End With
   
Set ADOcmd = Nothing

Open in new window

0
 
LVL 1

Expert Comment

by:RSHAH03
ID: 22811312
0
 

Author Comment

by:Schuttend
ID: 22816319
I noticed that a value is send from vb6 code to the stored procedure.
Is it also possible to have a return value?

regards,
Dennis
ALTER PROCEDURE [dbo].[importeren5] 
	
AS
    -- Insert statements for procedure here
	drop table CSVtest99
	create Table CSVtest99
	(	Datum  VARCHAR(30),
	Signal VARCHAR(30),
	Equity VARCHAR(30)
	
	)
	
	BULK insert csvtest99
	FROM 'c:\structure\test.txt'
	WITH
	(
	FIELDTERMINATOR =',',
	ROWTERMINATOR = '\n'
	)
	
	

Open in new window

0
 
LVL 6

Accepted Solution

by:
openshac earned 125 total points
ID: 22817002
0

Featured Post

Free Tool: Port Scanner

Check which ports are open to the outside world. Helps make sure that your firewall rules are working as intended.

One of a set of tools we are providing to everyone as a way of saying thank you for being a part of the community.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

Most everyone who has done any programming in VB6 knows that you can do something in code like Debug.Print MyVar and that when the program runs from the IDE, the value of MyVar will be displayed in the Immediate Window. Less well known is Debug.Asse…
If you need to start windows update installation remotely or as a scheduled task you will find this very helpful.
Get people started with the utilization of class modules. Class modules can be a powerful tool in Microsoft Access. They allow you to create self-contained objects that encapsulate functionality. They can easily hide the complexity of a process from…
This lesson covers basic error handling code in Microsoft Excel using VBA. This is the first lesson in a 3-part series that uses code to loop through an Excel spreadsheet in VBA and then fix errors, taking advantage of error handling code. This l…

761 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question