473,396 Members | 1,789 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 473,396 software developers and data experts.

VB + Sql server Stored procedures

Hi...friends...
i am using Sql Server as backend ,how to call the Stored Procedure In parameters & Out Parameters using Vb :)
Jul 11 '06 #1
1 2791
sashi
1,754 Expert 1GB
Hi Ramesh,

i have been using the below code for years and it works fine on both the MSSQL 7.0 and MSSQL 2K.. hope its useful to you and hope it helps you to get started.. good luck my fren.. :)

Expand|Select|Wrap|Line Numbers
  1. Dim sServer As String
  2. Dim sUser As String
  3. Dim sPWD As String
  4. Dim sDatabase As String
  5.  
  6. Dim DBcon As New ADODB.Connection
  7. Dim objCmd As New ADODB.Command
  8. Dim objparameter As New ADODB.Parameter
  9. Dim objRs As New ADODB.Recordset
  10.  
  11.     sServer = "(local)"
  12.     sDatabase = "mydb"
  13.     sUser = "sa"
  14.     sPWD = "password"
  15.  
  16.     DBcon.ConnectionString = "Provider=sqloledb;" & _
  17.         "server=" & sServer & ";uid=" & sUser & ";pwd=" & sPWD & ";database=" & sDatabase
  18.     DBcon.CursorLocation = adUseClient
  19.     DBcon.Open
  20.  
  21.     objparameter.Direction = adParamInput
  22.     objparameter.Type = adVarChar
  23.     objparameter.Size = 5
  24.     objparameter.Value = "hello"
  25.     objCmd.Parameters.Append objparameter
  26.  
  27.     objCmd.ActiveConnection = DBcon
  28.     objCmd.CommandType = adCmdStoredProc
  29.     objCmd.CommandText = "s_mysp"
  30.     Set objRs = objCmd.Execute                       ' objCmd.Execute for no resultset
  31.  
  32.     set objRs.ActiveConnection = Nothing
  33.     Set objCmd = Nothing
  34.     DBcon.Close
  35.  
Jul 11 '06 #2

Sign in to post your reply or Sign up for a free account.

Similar topics

3
by: polytimi8 | last post by:
Hello, I would like to know if it is possible to create a form in Access2000, which would function like a calendar for 8 operating rooms in hospital, showing which hours are those closed for a...
2
by: Yves Touze | last post by:
Hi All, I'm trying to migrate from SQL Server 7.0 to SQL Server 2000. I've got some ASP page which call VB components that retrieve shaped recordsets from SQL Server using the MSDATASHAPE...
18
by: Robin Lawrie | last post by:
Hi again, another problem! I've moved from an Access database to SQL server and am now having trouble inserting dates and times into seperate fields. I'm using ASP and the code below to get the...
7
by: Teri Welch | last post by:
Hello, We maintain a VB6 front-end application using an Access 2000 database. All code and forms are in VB6. The program also uses several queries/reports defined in Access. For corporate...
5
by: gilles27 | last post by:
I've ready many of the posts on this and other newsgroups in which people describe working practices for source control of database scripts. We are looking to implement something similar in my...
11
by: jrefactors | last post by:
I want to know the differences between SQL Server 2000 stored procedures and oracle stored procedures? Do they have different syntax? The concept should be the same that the stored procedures...
15
by: brettclare | last post by:
I have linked a large SQL Server table to Access, however 'only' 2,195,439 records are shown and are available to query. Can I increase the size (cache??)/number of records showing in Access? ...
0
by: Amber | last post by:
Stored procedures are faster and more efficient than in-line SQL statements. In this article we will look at two SQL Server stored procedures; one using an input parameter and one not, and see how...
1
by: jobs | last post by:
I have a growning list of stored procedures that accept a single string as a parameter. The list and parameters are maintained in a table with two columns. Some of the Stored procedures take...
1
by: nde_plume | last post by:
I have a SQL Server database that is connected to a client server program via ADO. I want this same program to be able to use JET as the database back end (to provide a light alternative that...
0
by: ryjfgjl | last post by:
In our work, we often receive Excel tables with data in the same format. If we want to analyze these data, it can be difficult to analyze them because the data is spread across multiple Excel files...
0
by: emmanuelkatto | last post by:
Hi All, I am Emmanuel katto from Uganda. I want to ask what challenges you've faced while migrating a website to cloud. Please let me know. Thanks! Emmanuel
0
BarryA
by: BarryA | last post by:
What are the essential steps and strategies outlined in the Data Structures and Algorithms (DSA) roadmap for aspiring data scientists? How can individuals effectively utilize this roadmap to progress...
0
by: Hystou | last post by:
There are some requirements for setting up RAID: 1. The motherboard and BIOS support RAID configuration. 2. The motherboard has 2 or more available SATA protocol SSD/HDD slots (including MSATA, M.2...
0
by: Hystou | last post by:
Most computers default to English, but sometimes we require a different language, especially when relocating. Forgot to request a specific language before your computer shipped? No problem! You can...
0
Oralloy
by: Oralloy | last post by:
Hello folks, I am unable to find appropriate documentation on the type promotion of bit-fields when using the generalised comparison operator "<=>". The problem is that using the GNU compilers,...
0
by: Hystou | last post by:
Overview: Windows 11 and 10 have less user interface control over operating system update behaviour than previous versions of Windows. In Windows 11 and 10, there is no way to turn off the Windows...
0
tracyyun
by: tracyyun | last post by:
Dear forum friends, With the development of smart home technology, a variety of wireless communication protocols have appeared on the market, such as Zigbee, Z-Wave, Wi-Fi, Bluetooth, etc. Each...
0
agi2029
by: agi2029 | last post by:
Let's talk about the concept of autonomous AI software engineers and no-code agents. These AIs are designed to manage the entire lifecycle of a software development project—planning, coding, testing,...

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.