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 strongm on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

Help with script please - should be easy

Status
Not open for further replies.

jay24k

MIS
May 12, 2004
32
US
I'm trying to replace all apostaphes and I can't get this to work. Here is my script. In what format do I need this in to be able to work? Right now putting the variable addtrain in there doesn't go in my database at all. Please assist :)

<%
Set Conn = Server.CreateObject("ADODB.Connection")
Conn.open "DSN=abcds;UID=username;PWD=password;DATABASE=datadata"
Dim WONUM, TECH, ADDTRAIN, SATISEXP, COMMENTS
WONUM=Request.Querystring("WONUM")
TECH=Request.Querystring("TECH")
TODAY=Date()
IPADD=Request.ServerVariables("REMOTE_ADDR")

if not isempty(Request.Form("Add")) then
ADDTRAIN=Replace(TrainingExplain, "'", "''")
conn.Execute "insert into MISSurvey (WO_NUM, ResponseTime, Satisfaction, Satisfactionexplain, AdditionalTraining, " _
& " TrainingExplain, Notified, Overallexperience, Comments) values (', " _
& "'" & Request.Form("WO_NUM") & "', " _
& "'" & Request.Form("ResponseTime") & "', " _
& "'" & Request.Form("Satisfaction") & "', " _
& "'" & Request.Form("SatisfactionExplain") & "', " _
& "'" & Request.Form("AdditionalTraining") & "', " _
& "'" & ADDTRAIN & "', " _
& "'" & Request.Form("Notified") & "', " _
& "'" & Request.Form("Overallexperience") & "', " _
& "'" & Request.Form("Comments") & "')"

response.redirect "survey.asp"
end if
%>

 
Quick note, this was on my test page so the ', right after values is not actually there. it is

& " TrainingExplain, Notified, Overallexperience, Comments) values (" _
 
ADDTRAIN=Replace(TrainingExplain, "'", "''")
Where is TrainingExplain coming from ?

Hope This Helps, PH.
Want to get great answers to your Tek-Tips questions? Have a look at FAQ219-2884 or FAQ222-2244
 
Ok well I tried a different way and it works however I can't seem to write a value to my database as a numeric when called from a querystring.

Sample code is this.

If isnumeric (Request.Querystring("WONUM")) then
WONUM= Request.Querystring("WONUM")
sql_insert = "insert into MISSurvey (WO_NUM) values (" & WONUM & ")"
Else
WONUM=9999
sql_insert = "insert into MISSurvey (WO_NUM) values (" & WONUM & ")"
End If

Once I finish the connection it bombs out. Now if I change it to
If not isnumeric it writes the 9999 no problem. I hope this makes sense.

THanks
 
it bombs out
Any error message ?
Have you tried to dump/display somewhere the contents of sql_insert ?

Hope This Helps, PH.
Want to get great answers to your Tek-Tips questions? Have a look at FAQ219-2884 or FAQ222-2244
 
The error is a error in the string. However if I do it where it calls the querystring in the insert, it says I can't do it because it can't convert to numberic. MY DB is set to numeric but it wants to do string.
 
Have you tried something like this ?
If IsNumeric(Request.Querystring("WONUM")) Then
WONUM=CLng(Request.Querystring("WONUM"))
Else
WONUM=9999
End If
sql_insert="INSERT INTO MISSurvey (WO_NUM) VALUES (" & WONUM & ")"

Hope This Helps, PH.
Want to get great answers to your Tek-Tips questions? Have a look at FAQ219-2884 or FAQ222-2244
 
Nope but I'll try it in the morning.

Thanks!
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top