|
crosscreek -> RE: understanding stored procedures (3/31/2008 13:38:37)
|
I will post their as well. I don't like posting in multiple forums with the same question at the same time. I googled & found most people asking the question. I did come up with somthing like this, but I will admit I am not really sure of this procedure...commands are very new to me. So are subs. This is one way <%@ Language=VBScript %> <% 'Option Explicit %> <!-- #include virtual="/adovbs.inc" --> <% Main() Public Sub Main() Dim oCommand Set oCommand = Server.CreateObject("ADODB.Command") oCommand.ActiveConnection = "DRIVER={MYSQL};SERVER=XXXXX;PORT=3306;OPTION=16384;DATABASE=XXXX;UID=XXXX;PWD=XXXX" oCommand.CommandText = "sp_pedi" oCommand.CommandType = adCmdStoredProc Dim oParameter Set oParameter = oCommand.CreateParameter("myinput", adInteger, adParamInput, 4, myinput) oCommand.Parameters.Append oParameter Dim oRecordset Set oRecordset = oCommand.Execute End Sub %> CREATE PROCEDURE sp_pedi ( @myinput int ) AS SELECT id, name FROM tbldog WHERE tbldog.id = @myinput <% Another way I found is: <!-- #include virtual="/adovbs.inc" --> <!-- #include file="myconn.inc" --> Dim cmd set cmd = Server.CreateObject("ADODB.Command") ' the connection could vary depending on your sql server. cmd.ActiveConnection = myconn cmd.CommandText = "sp_pedi" cmd.CommandTimeout = 30 cmd.CommandType = 4 'same as adCmdStoredProc cmd.Prepared = true ' the parametes are parameter in sproc, type, direction, size, value cmd.Parameters.Append cmd.CreateParameter("@myinput") cmd.Execute() But then I am not sure how to execute the SP in the SQL of my asp code Dim SQL, myin myin = 1 SQL = "Execute sp_Pedi" & myinput I understand the theory behind SP's just not how to get them to execute.
|
|
|
|