sql update errors - Programmers Heaven

Howdy, Stranger!

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

Categories

Welcome to the new platform of Programmer's Heaven! We apologize for the inconvenience caused, if you visited us from a broken link of the previous version. The main reason to move to a new platform is to provide more effective and collaborative experience to you all. Please feel free to experience the new platform and use its exciting features. Contact us for any issue that you need to get clarified. We are more than happy to help you.

sql update errors

im trying to update to the database with the following sql statements:

FUNCTION fixQuotes( theString )
fixQuotes = REPLACE( theString, "'", "''" )
END FUNCTION

sql #1
sqlstring = "update Asset set AssetID='"&fixQuotes( assetid )&"', AssetLabel='"&fixQuotes( assetlabel )&"', WarrantStart='"&fixQuotes( warrantystart )&"', Engrave='"&fixQuotes( engrave )&"', Status='"&fixQuotes( status1 )&"', Make='"&fixQuotes( make )&"', Model='"&fixQuotes( model )&"', AssetCategory='"&fixQuotes( assetcategory )&"' where AssetID='"&assetid&"' "

sql #2
sqlstring = "update Asset set " &_
"AssetID=' " & fixQuotes( assetid ) & "'," &_
"AssetLabel=' " & fixQuotes( assetlabel ) & "'," &_
"WarrantStart=' " & fixQuotes( warrantystart ) & "'," &_
"Engrave=' " & fixQuotes( engrave ) & "'," &_
"Status=' " & fixQuotes( status1 ) & "'," &_
"Make=' " & fixQuotes( make ) & "'," &_
"Model=' " & fixQuotes( model ) & "'," &_
"AssetCategory=' " & fixQuotes( assetcategory ) & "' where " &_
"AssetID=" & AssetID

i didnt get any error messages. the syntax looks correct just that it doesnt update.

Comments

  • FlakesFlakes Posts: 642Member
    : im trying to update to the database with the following sql statements:
    :
    : FUNCTION fixQuotes( theString )
    : fixQuotes = REPLACE( theString, "'", "''" )
    : END FUNCTION
    :
    : sql #1
    : sqlstring = "update Asset set AssetID='"&fixQuotes( assetid )&"', AssetLabel='"&fixQuotes( assetlabel )&"', WarrantStart='"&fixQuotes( warrantystart )&"', Engrave='"&fixQuotes( engrave )&"', Status='"&fixQuotes( status1 )&"', Make='"&fixQuotes( make )&"', Model='"&fixQuotes( model )&"', AssetCategory='"&fixQuotes( assetcategory )&"' where AssetID='"&assetid&"' "
    :
    : sql #2
    : sqlstring = "update Asset set " &_
    : "AssetID=' " & fixQuotes( assetid ) & "'," &_
    : "AssetLabel=' " & fixQuotes( assetlabel ) & "'," &_
    : "WarrantStart=' " & fixQuotes( warrantystart ) & "'," &_
    : "Engrave=' " & fixQuotes( engrave ) & "'," &_
    : "Status=' " & fixQuotes( status1 ) & "'," &_
    : "Make=' " & fixQuotes( make ) & "'," &_
    : "Model=' " & fixQuotes( model ) & "'," &_
    : "AssetCategory=' " & fixQuotes( assetcategory ) & "' where " &_
    : "AssetID=" & AssetID
    :
    : i didnt get any error messages. the syntax looks correct just that it doesnt update.
    :


    have you checked what the sql really is ?

    Response.write "DEBUG :sql #1 = "& sqlstring



  • frag_mentfrag_ment Posts: 25Member
    : : im trying to update to the database with the following sql statements:
    : :
    : : FUNCTION fixQuotes( theString )
    : : fixQuotes = REPLACE( theString, "'", "''" )
    : : END FUNCTION
    : :
    : : sql #1
    : : sqlstring = "update Asset set AssetID='"&fixQuotes( assetid )&"', AssetLabel='"&fixQuotes( assetlabel )&"', WarrantStart='"&fixQuotes( warrantystart )&"', Engrave='"&fixQuotes( engrave )&"', Status='"&fixQuotes( status1 )&"', Make='"&fixQuotes( make )&"', Model='"&fixQuotes( model )&"', AssetCategory='"&fixQuotes( assetcategory )&"' where AssetID='"&assetid&"' "
    : :
    : : sql #2
    : : sqlstring = "update Asset set " &_
    : : "AssetID=' " & fixQuotes( assetid ) & "'," &_
    : : "AssetLabel=' " & fixQuotes( assetlabel ) & "'," &_
    : : "WarrantStart=' " & fixQuotes( warrantystart ) & "'," &_
    : : "Engrave=' " & fixQuotes( engrave ) & "'," &_
    : : "Status=' " & fixQuotes( status1 ) & "'," &_
    : : "Make=' " & fixQuotes( make ) & "'," &_
    : : "Model=' " & fixQuotes( model ) & "'," &_
    : : "AssetCategory=' " & fixQuotes( assetcategory ) & "' where " &_
    : : "AssetID=" & AssetID
    : :
    : : i didnt get any error messages. the syntax looks correct just that it doesnt update.
    : :
    :
    :
    : have you checked what the sql really is ?
    :
    : Response.write "DEBUG :sql #1 = "& sqlstring
    :
    :
    :
    :
    theres no output from the response.write
  • FlakesFlakes Posts: 642Member
    : : : im trying to update to the database with the following sql statements:
    : : :
    : : : FUNCTION fixQuotes( theString )
    : : : fixQuotes = REPLACE( theString, "'", "''" )
    : : : END FUNCTION
    : : :
    : : : sql #1
    : : : sqlstring = "update Asset set AssetID='"&fixQuotes( assetid )&"', AssetLabel='"&fixQuotes( assetlabel )&"', WarrantStart='"&fixQuotes( warrantystart )&"', Engrave='"&fixQuotes( engrave )&"', Status='"&fixQuotes( status1 )&"', Make='"&fixQuotes( make )&"', Model='"&fixQuotes( model )&"', AssetCategory='"&fixQuotes( assetcategory )&"' where AssetID='"&assetid&"' "
    : : :
    : : : sql #2
    : : : sqlstring = "update Asset set " &_
    : : : "AssetID=' " & fixQuotes( assetid ) & "'," &_
    : : : "AssetLabel=' " & fixQuotes( assetlabel ) & "'," &_
    : : : "WarrantStart=' " & fixQuotes( warrantystart ) & "'," &_
    : : : "Engrave=' " & fixQuotes( engrave ) & "'," &_
    : : : "Status=' " & fixQuotes( status1 ) & "'," &_
    : : : "Make=' " & fixQuotes( make ) & "'," &_
    : : : "Model=' " & fixQuotes( model ) & "'," &_
    : : : "AssetCategory=' " & fixQuotes( assetcategory ) & "' where " &_
    : : : "AssetID=" & AssetID
    : : :
    : : : i didnt get any error messages. the syntax looks correct just that it doesnt update.
    : : :
    : :
    : :
    : : have you checked what the sql really is ?
    : :
    : : Response.write "DEBUG :sql #1 = "& sqlstring
    : :
    : :
    : :
    : :
    : theres no output from the response.write
    :


    That could be the problem . Can you show more code .


  • frag_mentfrag_ment Posts: 25Member
    <%
    FUNCTION fixQuotes( theString )
    fixQuotes = REPLACE( theString, "'", "''" )
    END FUNCTION

    addasset = trim(request("addasset"))
    updateasset = trim(request("updateasset"))

    assetid = trim(request("assetid"))
    assetlabel = trim(request("assetlabel"))
    warrantystart = trim(request("warrantystart"))
    engrave = trim(request("engrave"))
    status1 = trim(request("status1"))
    make = trim(request("make"))
    model = trim(request("model"))
    assetcategory = trim(request("assetcategory"))

    set conn=Server.CreateObject("ADODB.Connection")
    conn.Open "deployment"

    %>



    Manage Asset



    'add new asset
    if addasset <> "" then
    sqlstring = "INSERT INTO Asset VALUES ('"& assetid &"', '"& assetlabel &"', '"& warrantystart &"', '"& engrave &"', '"& status1 &"', '"& make &"', '"& model &"', '"& assetcategory &"');"

    'response.Write(sqlstring)
    conn.execute sqlstring
    %>
    <%=assetlabel%> successfully added to the database.
    <%
    conn.close
    set conn = nothing
    end if

    'update asset
    if updateasset <> "" then

    'sqlstring = "update Asset set AssetID='"&fixQuotes( assetid )&"', AssetLabel='"&fixQuotes( assetlabel )&"', WarrantStart='"&fixQuotes( warrantystart )&"', Engrave='"&fixQuotes( engrave )&"', Status='"&fixQuotes( status1 )&"', Make='"&fixQuotes( make )&"', Model='"&fixQuotes( model )&"', AssetCategory='"&fixQuotes( assetcategory )&"' where AssetID='"&assetid&"'"

    'sqlstring = "update Asset set AssetID='"& fixQuotes( assetid ) &"'," &_
    '"AssetLabel='"& fixQuotes( assetlabel ) &"'," &_
    '"WarrantStart='"& fixQuotes( warrantystart ) &"'," &_
    '"Engrave='"& fixQuotes( engrave ) &"'," &_
    '"Status='"& fixQuotes( status1 ) &"'," &_
    '"Make='"& fixQuotes( make ) &"'," &_
    '"Model='"& fixQuotes( model ) &"'," &_
    '"AssetCategory='"& fixQuotes( assetcategory ) &"' where AssetID='"& assetid &"'"

    sqlstring = "update Asset set AssetID='"& assetid &"', AssetLabel='"& assetlabel &"', WarrantStart='"& warrantystart &"', Engrave='"& engrave &"', Status='"& status1 &"', Make='"& make &"', Model='"& model &"', AssetCategory='"& assetcategory &"' where AssetID='"& assetid &"'"

    response.Write(sqlstring)
    conn.execute sqlstring
    %>
    <%=assetlabel%> successfully updated to the database.
    <%
    conn.close
    set conn = nothing
    end if
    %>
  • FlakesFlakes Posts: 642Member
    : <%
    : FUNCTION fixQuotes( theString )
    : fixQuotes = REPLACE( theString, "'", "''" )
    : END FUNCTION
    :
    : addasset = trim(request("addasset"))
    : updateasset = trim(request("updateasset"))
    :
    : assetid = trim(request("assetid"))
    : assetlabel = trim(request("assetlabel"))
    : warrantystart = trim(request("warrantystart"))
    : engrave = trim(request("engrave"))
    : status1 = trim(request("status1"))
    : make = trim(request("make"))
    : model = trim(request("model"))
    : assetcategory = trim(request("assetcategory"))
    :
    : set conn=Server.CreateObject("ADODB.Connection")
    : conn.Open "deployment"
    :
    : %>
    :
    :
    :
    : Manage Asset
    :
    :
    :
    : 'add new asset
    : if addasset <> "" then
    : sqlstring = "INSERT INTO Asset VALUES ('"& assetid &"', '"& assetlabel &"', '"& warrantystart &"', '"& engrave &"', '"& status1 &"', '"& make &"', '"& model &"', '"& assetcategory &"');"
    :
    : 'response.Write(sqlstring)
    : conn.execute sqlstring
    : %>
    : <%=assetlabel%> successfully added to the database.
    : <%
    : conn.close
    : set conn = nothing
    : end if
    :
    : 'update asset
    : if updateasset <> "" then
    :
    : 'sqlstring = "update Asset set AssetID='"&fixQuotes( assetid )&"', AssetLabel='"&fixQuotes( assetlabel )&"', WarrantStart='"&fixQuotes( warrantystart )&"', Engrave='"&fixQuotes( engrave )&"', Status='"&fixQuotes( status1 )&"', Make='"&fixQuotes( make )&"', Model='"&fixQuotes( model )&"', AssetCategory='"&fixQuotes( assetcategory )&"' where AssetID='"&assetid&"'"
    :
    : 'sqlstring = "update Asset set AssetID='"& fixQuotes( assetid ) &"'," &_
    : '"AssetLabel='"& fixQuotes( assetlabel ) &"'," &_
    : '"WarrantStart='"& fixQuotes( warrantystart ) &"'," &_
    : '"Engrave='"& fixQuotes( engrave ) &"'," &_
    : '"Status='"& fixQuotes( status1 ) &"'," &_
    : '"Make='"& fixQuotes( make ) &"'," &_
    : '"Model='"& fixQuotes( model ) &"'," &_
    : '"AssetCategory='"& fixQuotes( assetcategory ) &"' where AssetID='"& assetid &"'"
    :
    : sqlstring = "update Asset set AssetID='"& assetid &"', AssetLabel='"& assetlabel &"', WarrantStart='"& warrantystart &"', Engrave='"& engrave &"', Status='"& status1 &"', Make='"& make &"', Model='"& model &"', AssetCategory='"& assetcategory &"' where AssetID='"& assetid &"'"
    :
    : response.Write(sqlstring)
    : conn.execute sqlstring
    : %>
    : <%=assetlabel%> successfully updated to the database.
    : <%
    : conn.close
    : set conn = nothing
    : end if
    : %>
    :


    No obvious errors in there.

    Try this :

    [code]
    addasset = trim(request("addasset"))
    updateasset = trim(request("updateasset"))

    Response.Write "addasset="&addasset&"
    "
    Response.Write "updateasset="&updateasset&"
    "
    [/code]


    and see what it shows.
Sign In or Register to comment.