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

Trouble Updating Using an array - Need Assist Pls

Status
Not open for further replies.

baybook

MIS
Sep 16, 2004
66
0
0
US
'm using asp with a MySql page -- workingon someone elses work. I have a script that updates the datbase just fine, however, when I add a field to the form, the insert page no longer works. Can someone tell me why adding one field throughs the entire script off. The field has been added to my database.

This sql statement is created with an array and I usually create the sql statements by specifying fields. I am pasting the update script for anyone to review. Thanks

-----------------------------------
Public Function FixQuotes(ByVal strValue)
FixQuotes = Replace(Replace(Replace(trim(strValue), "'", "''"),chr(13)," "),chr(10),"")
End Function

Function sqlInsert(array,table_name)
strSql="select settingValue from settings where setting='pEncryptionPassword'"
set rs=conn.execute(strSql)
Pwd=rs(0)
set rs = nothing
For Each field in array
If len(array(field)) > 0 Then
columns = columns & field &","
If field = "card_number" Then
values = values & "encode('"& array(field) &"','"&Pwd&"'),"
Else
values = values & "'" & FixQuotes(array(field)) & "',"
End If
End If
Next
columns = StrReverse(Replace(StrReverse(columns),",","",1,1))
values = StrReverse(Replace(StrReverse(values),",","",1,1))

sqlInsert = "INSERT INTO " & table_name & " (time_stamp, " & columns & ")" & " VALUES ('"& MySqlDate(now) &"'," & values & ")"
End Function

conn.execute sqlInsert(request.form,"orders")
 
Can you add in a Response.Write after you have built the script, and dump it to the screen to see what the SQL is?

(And if you can see nothing wrong, try running that exact script against the database in a window, and see what the SQL error message is)
K
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top