|
-
Apr 6th, 2004, 09:52 AM
#1
Thread Starter
Frenzied Member
problems converting code
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.
-
Apr 6th, 2004, 10:02 AM
#2
Thread Starter
Frenzied Member
another thing that's throwing me off is where he uses:
I don't see a conn declared::?
-
Apr 6th, 2004, 11:23 AM
#3
Thread Starter
Frenzied Member
-
Apr 6th, 2004, 12:51 PM
#4
Well... first off in .NET, there is not such thing as the SET command.....as all things are now objects.
And I think conn was supposed to be objConn.....
TG
-
Apr 6th, 2004, 01:23 PM
#5
Thread Starter
Frenzied Member
Originally posted by techgnome
Well... first off in .NET, there is not such thing as the SET command.....as all things are now objects.
And I think conn was supposed to be objConn.....
TG
That's exactly what I thought thanks.
-
Apr 7th, 2004, 09:05 AM
#6
Thread Starter
Frenzied Member
ok, I finally got everything (for THIS problem)solved...for now lol
I ended up using ado.net (against my project leader's orders ) and used an sqlconnection, sqlcommand and made a function to hit the stored procedure and return a value for me.
Thanks for all the help y'all
Posting Permissions
- You may not post new threads
- You may not post replies
- You may not post attachments
- You may not edit your posts
-
Forum Rules
|
Click Here to Expand Forum to Full Width
|