|
|
|||||||||
|
|||||||||
|
|||||||||
| |
|||
| |||||||||
![]() |
|
|
«
Previous Thread
|
Next Thread
»
|
Thread Tools | Search this Thread | Display Modes |
|
|
|
Get inside! Sample the range of functionality easily built with JMSL Library for Time Series Data Analysis, Heat Maps, Portfolio Optimization, Monte Carlo Simulation, Stock Price Charting and more. Download Now! |
|
#1
|
|||
|
|||
|
hi,
Got the following on my asp page: Code:
sCategory = "Spy"
sName = request.Form("name")
sInfo = request.Form("info")
sDate = year(Date()) & "/" & month(Date()) & "/" & day(Date())
sReset = MonthName(month(Date()))
iNumber = 10
cmd.CommandText = "sqlEarthSpyAdd"
set rs = cmd.Execute (,, adCmdStoredProc)
Got the following as a querry in my access 2000 db: Code:
INSERT INTO
tblEarh ( Category, Name, [Number], Info, [Date], Reset )
VALUES ('" & sCategory & "','" & sName & "', _
" & iNumber & ", '" & sInfo & "', _
#" & sDate & "#, '" & sReset & "');
How do I get the above variables (ASP) into the querry (db)?? Is it even worth doing this as the querries aren't all that involved it just saves typing (copying) the same code 5-10 times (2 lines)? Thanks |
|
#2
|
|||
|
|||
|
Hi,
I assume that you need to generate just one SQL query to add a new record to your access database? I would just use an INSERT INTO query to do it. You don't need a stored procedure or anything fancy because if its just one insert then its automatically encapsulated into a transaction and if any errors occur it will be rolled back. what do you mean by 5-10 copies of it? do you have multiple insert queries that need to be done with the same/diff data? |
|
#3
|
|||
|
|||
|
thanks for that.
I am developing a helper for a game I play online, Earth: 2025, and when people attack me I ussually want to attack them back. But I'm not always strong enough then and there and have to build up some more. Also you can run spy attacks on people to find out what they got and don't got.
So the helper is simply a database of all this information and I have three pages that do the same thing (at the moment). So if I used a stored procedure all I would need is one page with variables that get filled in and from the variables the data go in the right places (thats where the 5-10 copies come in). you can have a look at what I got at the moment if you want here. username: guest password: guest You can see there are three headings Spy, Attacked, Deffended. Well all this is stored in the same table in the db just that some of the columns are different. Namely the category one. Hope you can see why I was asking about stored procedures. Nigorr |
|
#4
|
|||
|
|||
|
Somebody please help!
I would still like to know how to pass variable values to my stored quereies, please.
|
|
#5
|
|||
|
|||
|
To use a variable in a stored procedure, you would use the parameters.append method.
First, create an SQL query in your database with the variable inside it, like this Code:
SELECT tblUsr.usrID, tblUsr.usrName, tblUsr.usrRealName FROM tblUsr WHERE (((tblUsr.usrID)=[http_usrID])); http_usrID is the variable in that query. You can tell by the square brackets. So now that you have the query in the database, lets get to the ASP portion of it. Code:
set oCmdUsrInfo = Server.CreateObject("ADODB.Command")
set oRSUsrInfo = Server.CreateObject("ADODB.Recordset")
With oCmdCars
.ActiveConnection = oConn
.CommandText = "qryDisplayUser_byusrID"
.CommandType = adCmdStoredProc
.Parameters.Append .CreateParameter ("@http_usrID",adInteger,adParamInput,0) 'create the parameter
.Parameters("@http_usrID") = usrID ' set the parameter's value
Set oRSUsrInfo = .execute
End With
That should give you an idea as to how stored procedures work with variables. edit: one thing I forgot to mention; I always name the variable in the sql query with "http_" in front of it. This helps to keep things a lot simpler as far as remembering where the information is coming from, and also, you can't use a variable name that is the same as the field name, so this will keep that from happening as well. Last edited by transient : May 11th, 2002 at 03:08 PM. |
|
#6
|
|||
|
|||
|
Thanks for that, finally I know how to do it..!!
|
|
#7
|
|||
|
|||
|
No worries, I had a heck of a time with stored procedures when I first started.
|
![]() |
| Viewing: Dev Articles Community Forums > Programming > ASP Development > command.execute? |
| Thread Tools | Search this Thread |
| Display Modes | Rate This Thread |
|
|
|
|