SQL Update in ASP - Programmers Heaven

Howdy, Stranger!

It looks like you're new here. If you want to get involved, click one of these buttons!

Categories

SQL Update in ASP

This is the code I have used. This works apart from when the line with the * next to it is added. I think I may have missed out a comma or something as trivial as that.

strProvider="DRIVER=Microsoft Access Driver (*.mdb); DBQ=C:InetpubwwwrootWeb SiteSquashMetro.mdb;"
set conn = server.createobject("ADODB.Connection")
conn.Open strProvider

sqlstmt = "UPDATE PlayerResultsDiv1"
if GH1 = 3 then
Won = 1
sqlstmt = sqlstmt & " SET Won= Won + " & Won
else
Lost = 1
sqlstmt = sqlstmt & " SET Lost= Lost + " & Lost
end if

sqlstmt = sqlstmt & " Pts = Pts + " & GH1 **************


sqlstmt = sqlstmt & " WHERE PlayerID ='" & PH1 & "' "
Set RS = conn.execute(sqlstmt)

Thanks

Dave

Comments

  • ljubaljuba Posts: 106Member
    [b][red]This message was edited by ljuba at 2002-8-15 10:15:55[/red][/b][hr]
    If I understood, problem is in this line:

    sqlstmt = sqlstmt & " WHERE PlayerID ='" & PH1 & "' "

    I think PlayerID is numeric field You don't need ' around PH1

    it should be:

    sqlstmt = sqlstmt & " WHERE PlayerID =" & PH1 & " "

    or

    sqlstmt = sqlstmt & " WHERE PlayerID =" & PH1

    LJUBA


  • Dave101Dave101 Posts: 10Member
    PlayerID was a text field.

    I found the problem. On the next line the statement had to start with a comma, for example

    sqlstmt = sqlstmt & ",Pts = Pts + " & PResult

    Thanks anyway



    : If I understood, problem is in this line:
    :
    : sqlstmt = sqlstmt & " WHERE PlayerID ='" & PH1 & "' "
    :
    : I think PlayerID is numeric field You don't need ' around PH1
    :
    : it should be:
    :
    : sqlstmt = sqlstmt & " WHERE PlayerID =" & PH1 & " "
    :
    : or
    :
    : sqlstmt = sqlstmt & " WHERE PlayerID =" & PH1
    :
    : LJUBA
    :
    :
    :

Sign In or Register to comment.