Current location: Hot Scripts Forums » Programming Languages » ASP » Passing a variable into an SQL


Passing a variable into an SQL

Reply
  #1 (permalink)  
Old 06-20-05, 08:32 PM
davemcdougall davemcdougall is offline
Newbie Coder
 
Join Date: Jun 2005
Posts: 6
Thanks: 0
Thanked 0 Times in 0 Posts
Passing a variable into an SQL

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
Reply With Quote
  #2 (permalink)  
Old 06-26-05, 09:29 AM
koncept
Guest
 
Posts: n/a
sorry i missed this one but here you go

Code:
 sqlsave = "INSERT INTO fib_treat (fib_treat_warr_id, fib_treat_regtrans, fib_treat_surname, fib_treat_date_treat, fib_treat_kit, fib_treat _del_cust)
  VALUES ('" & warranty_update &"','" & regtrans_update &"','" & request("surname") &"','" &request("date_treated") &"','" &request("kit") &"','" &request("del_date") &"')"
to put a variable into an sql statement, you would do it just like a form data. Can i suggest using option explicit at the top of your page and request.form (i'm assuming you posted the data and its not a get)
Reply With Quote
Reply

Bookmarks


Currently Active Users Viewing This Thread: 1 (0 members and 1 guests)
 
Thread Tools
Display Modes

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

BB code is On
Smilies are On
[IMG] code is Off
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are On

Forum Jump

Similar Threads
Thread Thread Starter Forum Replies Last Post
Passing a variable to another page tapir PHP 8 02-16-05 05:38 PM
Passing a PHP variable in Javascript??? todayscoffee JavaScript 2 01-08-05 09:45 AM
Passing a PHP variable in Javascript??? todayscoffee PHP 2 01-04-05 01:56 PM
Help with ASP & FORMS blessedrub ASP 0 01-23-04 10:22 AM
change my field in this example sal21 ASP 3 07-14-03 02:49 AM


All times are GMT -5. The time now is 03:24 PM.
vBulletin® Copyright ©2000 - 2012, Jelsoft Enterprises Ltd.