Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations Westi on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

Adding a record to SQL from ASP via Stored Procedure

Status
Not open for further replies.

Rexolio

Technical User
Aug 29, 2001
230
I have a SQL database table as follows:

TABLE NAME: tblClients
FIELDS: Name, Address, City, State, Zip

I have the following Stored Procedure:

SP NAME: spInsertClients

Now I'm having a problem figuring out how to call the SP from ASP in order to add records. Could someone provide me with some sample script? I posted an ealier message and someone recommended some other threads to check out, but they didn't have what I needed. Just looking for a sample based on what I've provided above. :)

Thanks,
Rex
 
Ok, if you just want to start the stored proc you need a connection and a command, here is the code:
dim comm
dim conn
set conn = server.createobject("adodb.connection")
set comm= server.createobject("adodb.command")
conn.open "***connectionstring"
With comm
.CommandText = "spInsertClients"
.CommandType = adCmdStoredProc
.Execute , , ADODB.adExecuteNoRecords
End With
set comm = nothing
conn.close
set conn = nothing

***connectionstring (this does not work in win ME but what does?)
You can make a connectionstring like this: make a new textfile and give it an .udl extention -> double click the udl file => you should get a datalink propertys screen, make your connection here and test it => open the udl file in notepad and the last line is your connectionstring.
if you need input parameters for your stored proc you can put them in like this



If you need to profide input parameters and or return parameters from the sproc to the asp please let me know.
 
harmmeijer,

yes i need need input parameters and return parameters from the sproc to the asp

thanks much!
rex
 
Here is you you give a parameter to the sproc, it is an integer with value 22. (see ms for more info)
comm.Parameters.Append comm.CreateParameter("@number", 3, 1, , 22)

Here is how you catch return parameters:
with comm
.Parameters.Append .CreateParameter("@outnum", adInteger, adParamOutput)
' you will notice I use adInteger instead of 3
' and adParamOutput instead of 2
' these things don't work in asp so use 3 and 2
.Execute , , ADODB.adExecuteNoRecords
intInteger = .Parameters("@outnum")

Check this url, I have to go, have a nice weekend

thread222-273886
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top