ASP Development
 
Forums: » Register « |  User CP |  Games |  Calendar |  Members |  FAQs |  Sitemap |  Support | 
 
User Name:
Password:
Remember me
 



Go Back   Dev Articles Community ForumsProgrammingASP Development

Reply
Add This Thread To:
  Del.icio.us   Digg   Google   Spurl   Blink   Furl   Simpy   Y! MyWeb 
Thread Tools Search this Thread Display Modes
 
Unread Dev Articles Community Forums Sponsor:
  #1  
Old April 14th, 2002, 10:28 PM
Nigorr Nigorr is offline
Contributing User
Dev Articles Newbie (0 - 499 posts)
 
Join Date: Apr 2002
Location: Brisbane, Australia
Posts: 78 Nigorr User rank is Just a Lowly Private (1 - 20 Reputation Level) 
Time spent in forums: < 1 sec
Reputation Power: 17
Question command.execute?

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

Reply With Quote
  #2  
Old April 15th, 2002, 09:30 AM
mytch mytch is offline
Dev Articles Novice (500 - 999 posts)
 
Join Date: Apr 2002
Location: Sydney, Australia
Posts: 588 mytch User rank is Just a Lowly Private (1 - 20 Reputation Level) 
Time spent in forums: < 1 sec
Reputation Power: 17
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?

Reply With Quote
  #3  
Old April 15th, 2002, 05:42 PM
Nigorr Nigorr is offline
Contributing User
Dev Articles Newbie (0 - 499 posts)
 
Join Date: Apr 2002
Location: Brisbane, Australia
Posts: 78 Nigorr User rank is Just a Lowly Private (1 - 20 Reputation Level) 
Time spent in forums: < 1 sec
Reputation Power: 17
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

Reply With Quote
  #4  
Old April 16th, 2002, 06:00 PM
Nigorr Nigorr is offline
Contributing User
Dev Articles Newbie (0 - 499 posts)
 
Join Date: Apr 2002
Location: Brisbane, Australia
Posts: 78 Nigorr User rank is Just a Lowly Private (1 - 20 Reputation Level) 
Time spent in forums: < 1 sec
Reputation Power: 17
Somebody please help!

I would still like to know how to pass variable values to my stored quereies, please.

Reply With Quote
  #5  
Old May 11th, 2002, 03:04 PM
transient transient is offline
Registered User
Dev Articles Newbie (0 - 499 posts)
 
Join Date: May 2002
Posts: 6 transient User rank is Just a Lowly Private (1 - 20 Reputation Level) 
Time spent in forums: < 1 sec
Reputation Power: 0
Send a message via AIM to transient
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.

Reply With Quote
  #6  
Old May 13th, 2002, 01:38 AM
Nigorr Nigorr is offline
Contributing User
Dev Articles Newbie (0 - 499 posts)
 
Join Date: Apr 2002
Location: Brisbane, Australia
Posts: 78 Nigorr User rank is Just a Lowly Private (1 - 20 Reputation Level) 
Time spent in forums: < 1 sec
Reputation Power: 17
Thanks for that, finally I know how to do it..!!

Reply With Quote
  #7  
Old May 13th, 2002, 08:56 AM
transient transient is offline
Registered User
Dev Articles Newbie (0 - 499 posts)
 
Join Date: May 2002
Posts: 6 transient User rank is Just a Lowly Private (1 - 20 Reputation Level) 
Time spent in forums: < 1 sec
Reputation Power: 0
Send a message via AIM to transient
No worries, I had a heck of a time with stored procedures when I first started.

Reply With Quote
Reply

Viewing: Dev Articles Community ForumsProgrammingASP Development > command.execute?


Developer Shed Advertisers and Affiliates


Thread Tools  Search this Thread 
Search this Thread:

Advanced Search
Display Modes  Rate This Thread 
Rate This Thread:


Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

vB code is On
Smilies are On
[IMG] code is On
HTML code is Off
View Your Warnings | New Posts | Latest News | Latest Threads | Shoutbox
Forum Jump

Forums: » Register « |  User CP |  Games |  Calendar |  Members |  FAQs |  Sitemap |  Support | 
  
 


Powered by: vBulletin Version 3.0.5
Copyright ©2000 - 2018, Jelsoft Enterprises Ltd.

© 2003-2018 by Developer Shed. All rights reserved. DS Cluster - Follow our Sitemap