Forum Moderators: mack

Message Too Old, No Replies

ASP Update Table (Access2003)

Syntax error in ASP build statement

         

heje

3:41 pm on Nov 15, 2005 (gmt 0)

10+ Year Member



Hi All,
Is there a kind soul who can help me with getting this ASP statement right. The combinations of " and ' have perplexed me for the whole day producing assorted "expected end of statement" syntax errors:

'Update Table:Xyz
strSQL = "Update Xyz set "
strSQL = strSQL & "AaaID= Session("AaaIDDvar") & ','"
strSQL = strSQL & "AaaDate= Session("AaaDateVar") & ','"
strSQL = strSQL & "AaaTime= Session("AaaTimeVar") & ','"
strSQL = strSQL & "Where Xyz = 'GetRequestForm("masterkey")'"
dbConnection.Execute strSQL

Regards
Heje

BradleyT

3:54 pm on Nov 15, 2005 (gmt 0)

10+ Year Member



Try

'Update Table:Xyz
strSQL = "Update Xyz set "
strSQL = strSQL & "AaaID= '" & Session("AaaIDDvar") & ',"
strSQL = strSQL & "AaaDate= '" & Session("AaaDateVar") & ',"
strSQL = strSQL & "AaaTime= '" & Session("AaaTimeVar") & ' "
strSQL = strSQL & "Where Xyz = '" & GetRequestForm("masterkey") & "'"
dbConnection.Execute strSQL

haggul

3:56 pm on Nov 15, 2005 (gmt 0)

10+ Year Member



Try :

'Update Table:Xyz
strSQL = "Update Xyz set "
strSQL = strSQL & "AaaID=" & Session("AaaIDDvar") & ","
strSQL = strSQL & "AaaDate=#" & Session("AaaDateVar") & "#,"
strSQL = strSQL & "AaaTime=#" & Session("AaaTimeVar") & "#,"
strSQL = strSQL & "Where Xyz = " & Request.Form("masterkey")
dbConnection.Execute strSQL

This assumes though that AaaID is numeric, AaaDate and AaaTime are datetime fields and Xyx in your where clause is the name of a numeric field within the Xyz table not the table name itself

heje

7:15 pm on Nov 15, 2005 (gmt 0)

10+ Year Member



Thanks a lot BradleyT and Haggul:

I had to change your suggestions a little bit:

1) the value regarding the masterkey was changed to a session variable because the other methods didn't work. The statement you helped with is to be inserted into a complex code (produced by a Code generator) having an internal architecture and system variables I do not fully understand at this point in time.

2) I removed the "#" from the line regarding ActionTime because this really is a text field which I should have stated.

3) I removed the "," in the line re AaaTimeVar

strSQL = "Update Xyz set "
strSQL = strSQL & "AaaID=" & Session("AaaIDvar") & ","
strSQL = strSQL & "AaaDate=#" & Session("AaaDateVar") & "#,"
strSQL = strSQL & "AaaTime=" & Session("AaaTimeVar") & " "
strSQL = strSQL & "Where XyzID = " & session("masterkeyvar")

dbConnection.Execute strSQL

Once again - Thank you so very much for your help.

All the best
Heje