ASP Hosting sale!
Double disk space and transfer for FREE!
Limited time offer! Act Now!

aspdev | articles | tutorials | forums

 FAQFAQ   SearchSearch   MemberlistMemberlist   UsergroupsUsergroups   RegisterRegister 
 ProfileProfile   Log in to check your private messagesLog in to check your private messages   Log inLog in 

Passing a variable into an SQL

 
Post new topic   Reply to topic    ASPdev.org Forum Index -> ASP programming
View previous topic :: View next topic  
Author Message
davemcdougall



Joined: 17 Jun 2005
Posts: 2

PostPosted: Mon Jun 20, 2005 8:30 pm    Post subject: Passing a variable into an SQL Reply with quote

Hello,

I am trying to make a variable appear in an SQl but am not sure how. Here is the sample code...


if Request("regtrans") = "" then
regtrans_update = "null"
else
regtrans_update = Request("regtrans")
end if

if Request("warranty") = "" then
warranty_update = "null"
else
warranty_update = Request("warranty")
end if

sqlsave = "INSERT INTO fib_treat (fib_treat_warr_id,fib_treat_regtrans,fib_treat_su rname,fib_treat_date_treat,fib_treat_kit,fib_treat _del_cust) VALUES ('" &Request("warranty_update") &"','" &Request("regtrans_update") &"','" &escapesql(Request("surname")) &"','" &Request("date_treated") &"','" &Request("kit") &"','" &Request("del_date") &"')"
objConn.Execute sqlsave

All the fields are coming from a form which has been submitted. I I do Response.Write Ion the variables...

Response.Write regtrans_update
Response.Write warranty_update

It show's the correct responses as per the if statements above. I just don't know how to get the variable into the SQL?

Any idea's?

Dave
Back to top
View user's profile Send private message
administrator
Site Admin


Joined: 01 Oct 2004
Posts: 183

PostPosted: Tue Jun 28, 2005 8:05 am    Post subject: Reply with quote

Instead of Request("regtrans_update") and Request("warranty_update") use directly regtrans_update and warranty_update:

sqlsave = "INSERT INTO fib_treat (fib_treat_warr_id,fib_treat_regtrans,fib_treat_su rname,fib_treat_date_treat,fib_treat_kit,fib_treat _del_cust) VALUES ('" & warranty_update &"','" & regtrans_update &"','" &escapesql(Request("surname")) &"','" &Request("date_treated") &"','" &Request("kit") &"','" &Request("del_date") &"')"
_________________
Peter
ASP & ASP.NET Articles and Tutorials
Back to top
View user's profile Send private message
Display posts from previous:   
Post new topic   Reply to topic    ASPdev.org Forum Index -> ASP programming All times are GMT - 5 Hours
Page 1 of 1

 
Jump to:  
You cannot post new topics in this forum
You cannot reply to topics in this forum
You cannot edit your posts in this forum
You cannot delete your posts in this forum
You cannot vote in polls in this forum


Powered by phpBB © 2001, 2002 phpBB Group

SQL Tutorial