Library code snippets
ADO Command and Stored Procedures
- Introduction
- Connection members
- Refreshing Parameters
Introduction
You can design stored procedures to hide such complexities, leaving a more concise interface available for application development.
The command object has the power to change the query each time it is used. The code below demonstrates how to use the ADO command object with these stored procedure. First, create the command object and connect the connection object to the command object.
'create a command object
set cm = Server.CreateObject("ADODB.Command")
'connect the command
cm.ActiveConnection = cn
Next, specify the query.
Method 1
set cm.CommandText = "Select * from schools"
Method 2 (Table)
set cm.CommandText = "schools"
cm.CommandType = adCmdTable
Method 3 (Stored Procedure)
set cm.CommandText = "add_school"
cmdCommandType = adCmdStoredProc
Method 4 (Stored Procedure with Parameters)
set cm.CommandText = "add_school"
cm.cmdCommandType = adCmdStoredProc
set p = cm.Parameters
p.Append cm.CreateParameter("@style",adChar,adParamInput,50)
p.Append cm.CreateParameter("@school", adChar, adParamInput,50)
p.Append cm.CreateParameter("@id",adInteger,adParamInput)
cm("@style") = "Kempo"
cm("@school") = "WSU"
cm(Id) = 1
cm.execute
Method 5 ( Return the results to a recordset)
rs.Open cm, cn
Method 6 ( Recordset, type, and locking method)
rs.Open cm, cn, adOpenKeyset, adLockOptimistic
Related articles
Related discussion
-
Help to Call ASP function from onclick event in HTML to pass an array
by vka (0 replies)
-
Binary Studio | software development outsourcing Ukraine
by shane124 (4 replies)
-
Variable In Vb.Net
by chia (0 replies)
-
ideas in building a captive portal
by sjranjan (2 replies)
-
How to debug classic ASP pages during AJAX calls in ASP.NET website
by andwan0 (0 replies)
Related podcasts
-
Scott Guthrie
Scott catches up with Scott Guthrie in an interview covering Ajax, Asp 2.0, extender controls, CSS adapters and more.
HI I was wondering if anyone knows how to run a stored procedure prefrable from a .sql file against a new database in VB?
I would be very gratful for you help.
Chris
How do you easy add or update a recordset when you have opened it using a stored procedure?
I'm making a program where the user sees a recordset as a grid (used SP). The user can edit rows or add new ones by going into detail mode. (I use a tabstrip where Grid is on the first and a detail frame is on the second tab.) When user goes into editmode I want the user to manipulate the record and be able to update or add.
But it seems that SP only return readonly recordsets. Is that so?
How do one then implement the grid/detail scenario when using stored procedures?
Examples are preferred!!
regards
Svein Are Gronsund, Norway
This thread is for discussions of ADO Command and Stored Procedures.