ok, I found this sample on the internet:http://authors.aspalliance.com/steve...les/sprocs.asp
I can't seem to figure out how to make it optimal for vb.net
Below is the sample code and below that, my code. I have mine in a function and it's called from a try block so I don't know what error exactly is being caught (I COULD, just too lazy right now lol)
What I'm having problems with is the SET command, I THINK I got that, you tell me.
VB Code:
Dim objConn Dim objCmd 'Instantiate objects Set objConn = Server.CreateObject("ADODB.Connection") set objCmd = Server.CreateObject("ADODB.Command") conn.Open Application("ConnectionString") With objCmd .ActiveConnection = conn 'You can also just specify a connection string here .CommandText = "sp_InsertArticle" .CommandType = adCmdStoredProc 'Requires the adovbs.inc file or typelib meta tag 'Add Input Parameters .Parameters.Append .CreateParameter("@columnist_id", adDouble, adParamInput, , columnist_id) .Parameters.Append .CreateParameter("@url", adVarChar, adParamInput, 255, url) .Parameters.Append .CreateParameter("@title", adVarChar, adParamInput, 99, url) .Parameters.Append .CreateParameter("@description", adLongVarChar, _ adParamInput, 2147483647, description) 'Add Output Parameters .Parameters.Append .CreateParameter("@link_id", adInteger, adParamOutput, , 0) 'Execute the function 'If not returning a recordset, use the adExecuteNoRecords parameter option .Execute, , adExecuteNoRecords link_id = .Parameters("@link_id") End With
VB Code:
Public Function GetTicketNumber(ByVal Customer As String) As Integer 'Purpose : gets a ticket number for each ticket. SP in database 'Accepts : customer name 'Notes : SP does all the work Dim i As Integer With AdoCmd .ActiveConnection = DB .CommandText = "GenerateTicketNumber" .CommandType = ADODB.CommandTypeEnum.adCmdStoredProc .Parameters.Append(.CreateParameter("@Name", ADODB.DataTypeEnum.adChar, ADODB.ParameterDirectionEnum.adParamInput, , Customer)) .Parameters.Append(.CreateParameter("@TicketNumber", ADODB.DataTypeEnum.adInteger, ADODB.ParameterDirectionEnum.adParamInputOutput, , 0)) .Execute() End With End Function
Here are the variables. I use the connection and recordse objects throughout the project. It may be that I can't use those same objects in my adocmd object?
VB Code:
Public DB As New ADODB.Connection 'This is for a global ado database connection Public RS As New ADODB.Recordset 'This is for a global ado recordset Public AdoCmd As New ADODB.Command 'Used for Stored Procedures
I am TOTALY lost on this one. I don't have an option BUT to use ado or I'd use ado.net.![]()
![]()
![]()
![]()
![]()
![]()




Reply With Quote