Results 1 to 9 of 9

Thread: [Resolved] Can ADD and DELETE from mDB but not UPDATE..?!?!

  1. #1

    Thread Starter
    Hyperactive Member
    Join Date
    Oct 2001
    Location
    www.alexdata.com
    Posts
    484

    Exclamation [Resolved] Can ADD and DELETE from mDB but not UPDATE..?!?!

    This is the code i use to UPDATE within my page.. but it doesnt update anything, it doesnt do anything, nor doest it trow any errors..
    Can someone look over my code (i'll upload the ASP page,and the mdb)
    (PS: the DB was renamed to .txt , because the upload system here doesnt accept .mdb as extension...dunno why??)

    Here's the code that create's the "problem" (it doesnt update the DB)
    Code:
      ELSEIF Request.Form("flag")="2" THEN
        SQLstmt = "UPDATE Produkter SET "
        SQLstmt = SQLstmt & "Varenavn='" & TRIM(Request.Form("Varenavn")) & "', "
        SQLstmt = SQLstmt & "Varenummer='" & TRIM(Request.Form("Varenummer")) & "', "
        SQLstmt = SQLstmt & "Varepris='" & TRIM(Request.Form("Varepris")) & "', "
        SQLstmt = SQLstmt & "Varetekst='" & TRIM(Request.Form("Varetekst")) & "', "
        SQLstmt = SQLstmt & " WHERE ID=" & TRIM(Request.Form("Recordid"))
    Attached Files Attached Files
    Last edited by alexdata; Dec 12th, 2005 at 02:48 PM. Reason: [Resolved] - See the last few posts..
    ***************
    Please use [highlight=vb] ..your code.. [/highlight] when posting code!

    When you have received the working answer to your question,
    please mark it as *SOLVED* + Your Questions Title ...using your Thread's Tool menu.


    Also try to point out what answer made it work for you, or edit your first post to contain a quote of the correct answer...

    Please Answer All Questions With Working Code Examples...


    My Unfinished Projects and My working Programs
    ***************

  2. #2
    Fanatic Member kaihirst's Avatar
    Join Date
    Jul 2005
    Location
    The Resaurant At the End of The Universe
    Posts
    633

    Re: Can ADD and DELETE from mDB but not UPDATE..?!?!

    Hi,

    If its not thortwing any errors at alll and the code is not updating or transacting to teh MDB, then it is probably the connectionstring or the connection itself is not executing at all, therefore not executing the statement. check the following.

    1. any case or boolean ilogical statements that may be in operation to trigger the instance off, they may be not triggereing, the string literals may be incorrect, or a naming convention could be at fault.

    2. If in the event that your connection string is in a function or class, make sure that the class is properly instantiated or initialised when needed or prompted by your application.

    3. Check any execution statements that triggers the query off such as your recordset or your connection object, they may be at fault or not instantiating properly.

    Check these points and get back to me.

    Hope this helps

    Kai
    As the information I give is useful in its nature, consider using the RATE POST feature located on the bottom left of this post please..

    A few things that make a good Developer a Great One.
    Methodical and a thorough approach to research and design inevitably leads to success.
    Forward thinking is the key to Flow of control.
    Never test in the design environment, always test in real time, you get the REAL results.
    CBSE & OOSE are the same animal, they just require different techniques, and thinking.
    SEO is a globe of objectives, SE rankings is an end to a means for these objectives, not part of them.
    The key to good design is explicit attention to both detail and response.
    Think Freely out of the "Box" you're in..... You will soar to better heights.

    Kai Hirst - MSCE, MCDBA, MCSD, MCP, MCAP, MSCT


  3. #3

    Thread Starter
    Hyperactive Member
    Join Date
    Oct 2001
    Location
    www.alexdata.com
    Posts
    484

    Exclamation Re: Can ADD and DELETE from mDB but not UPDATE..?!?!

    Well.. my connection and all is OK.. but now that i changed some stuff, it trows me an error

    See below code that should do the UPDATE..
    (or download the DB from the prev post + the ASP in this post...and try yourself)

    Microsoft OLE DB Provider for ODBC Drivers (0x80040E14)
    [Microsoft][ODBC Microsoft Access Driver] Syntakserror in UPDATE-string
    /ASPnettbutikk/butikk.asp, linje 127

    VB Code:
    1. 'If the QueryString has the Actionvar = update then generate
    2. 'the page for updating items
    3. ELSEIF Actionvar="update" THEN
    4.   IF Len(TRIM(Request.Form("flag"))) = 0 THEN
    5.     SQLstmt = "SELECT * FROM Produkter WHERE ID=" & Request.QueryString("Recid")
    6.     %>
    7.    
    8. <HR>
    9. <!--
    10. SQL statement: <%=SQLstmt%>
    11. <HR>
    12. -->
    13.     <%
    14.     Set rs = conn.Execute(SQLstmt)
    15.     IF NOT RS.EOF THEN
    16.     %>
    17.       <font color="red">Rediger dette produktet</font>
    18.       <FORM METHOD="post" ACTION=" butikk.asp?Actionvar=update">
    19.       <B>Varenavn:</B> <INPUT TYPE="text" NAME="Varenavn" VALUE="<%=rs("Varenavn")%>"><BR>
    20.       <B>Varenummer:</B> <INPUT TYPE="text" NAME="Varenummer" VALUE="<%=rs("Varenummer")%>"><BR>
    21.       <B>Varepris:</B> <INPUT TYPE="text" NAME="Varepris" VALUE="<%=rs("Varepris")%>"><BR>
    22. <B>Varetekst:</B> <INPUT TYPE="text" NAME="Varetekst" VALUE="<%=rs("Varetekst")%>"><BR>
    23.       <INPUT TYPE="hidden" NAME="flag" VALUE="2">
    24.       <INPUT TYPE="hidden" NAME="Recordid" VALUE="<%=rs("ID")%>">
    25.       <INPUT TYPE="submit" VALUE="Lagre endringer">
    26.       </FORM>
    27.       <%
    28.       rs.MoveNext
    29.       rs.Close
    30.     END IF
    31.  
    32.  
    33. 'ELSEIF Request.Form("flag")="2" THEN
    34. '    SQLstmt = "UPDATE Prices SET "
    35. '    SQLstmt = SQLstmt & "Varenavn='" & TRIM(Request.Form("Varenavn")) & "', "
    36. '    SQLstmt = SQLstmt & "Varenummer='" & TRIM(Request.Form("Varenummer")) & "', "
    37. '    SQLstmt = SQLstmt & "Varepris=" & TRIM(Request.Form("Varepris"))
    38. '    SQLstmt = SQLstmt & " WHERE ID=" & TRIM(Request.Form("Recordid"))
    39.    
    40.   ELSEIF Request.Form("flag")="2" THEN
    41.     SQLstmt = "UPDATE Produkter SET "
    42.     SQLstmt = SQLstmt & "Varenavn='" & TRIM(Request.Form("Varenavn")) & "', "
    43.     SQLstmt = SQLstmt & "Varenummer=" & TRIM(Request.Form("Varenummer")) & ", "
    44.     SQLstmt = SQLstmt & "Varepris=" & TRIM(Request.Form("Varepris")) & ", "
    45.     SQLstmt = SQLstmt & "Varetekst='" & TRIM(Request.Form("Varetekst")) & "', "
    46.     SQLstmt = SQLstmt & " WHERE ID=" & TRIM(Request.Form("Recordid"))
    47. %>
    48.     <HR>
    49.    
    50. <!--
    51. SQL statement: <%=SQLstmt%>
    52. <HR>
    53. -->
    54.     <%
    55.     Conn.Execute (SQLstmt)
    56. response.write SQLstmt & "<br>"  
    57.      Response.Write "Varen er nå blitt redigert!<br><A HREF=""butikk.asp"">Gå tilbake..</A>"
    58.   END IF
    Attached Files Attached Files
    ***************
    Please use [highlight=vb] ..your code.. [/highlight] when posting code!

    When you have received the working answer to your question,
    please mark it as *SOLVED* + Your Questions Title ...using your Thread's Tool menu.


    Also try to point out what answer made it work for you, or edit your first post to contain a quote of the correct answer...

    Please Answer All Questions With Working Code Examples...


    My Unfinished Projects and My working Programs
    ***************

  4. #4
    Fanatic Member kaihirst's Avatar
    Join Date
    Jul 2005
    Location
    The Resaurant At the End of The Universe
    Posts
    633

    Re: Can ADD and DELETE from mDB but not UPDATE..?!?!

    Hi,

    right then, were getting somewhere now..

    VB Code:
    1. 'ELSEIF Request.Form("flag")="2" THEN
    2.  
    3. '    SQLstmt = "UPDATE Prices SET "
    4. '    SQLstmt = SQLstmt & "Varenavn='" & TRIM(Request.Form("Varenavn")) & "', "
    5. '    SQLstmt = SQLstmt & "Varenummer='" & TRIM(Request.Form("Varenummer")) & "', "
    6. '    SQLstmt = SQLstmt & "Varepris='" & TRIM(Request.Form("Varepris")) & "',"
    7. '    SQLstmt = SQLstmt & " WHERE_ID='" & TRIM(Request.Form("Recordid")) &"'"

    As you can see, ive made some changes to your statement.

    1. the WHERE_ID never use spaces in your tables at all. So change this for what ive substituted adn youre away.

    2. Plus you missed some single quotes out and I have added them...

    try this and see how you get on.

    Kai
    Last edited by kaihirst; Dec 12th, 2005 at 01:15 PM.
    As the information I give is useful in its nature, consider using the RATE POST feature located on the bottom left of this post please..

    A few things that make a good Developer a Great One.
    Methodical and a thorough approach to research and design inevitably leads to success.
    Forward thinking is the key to Flow of control.
    Never test in the design environment, always test in real time, you get the REAL results.
    CBSE & OOSE are the same animal, they just require different techniques, and thinking.
    SEO is a globe of objectives, SE rankings is an end to a means for these objectives, not part of them.
    The key to good design is explicit attention to both detail and response.
    Think Freely out of the "Box" you're in..... You will soar to better heights.

    Kai Hirst - MSCE, MCDBA, MCSD, MCP, MCAP, MSCT


  5. #5

    Thread Starter
    Hyperactive Member
    Join Date
    Oct 2001
    Location
    www.alexdata.com
    Posts
    484

    Re: Can ADD and DELETE from mDB but not UPDATE..?!?!

    I get a new error here..
    Feiltype:
    Microsoft OLE DB Provider for ODBC Drivers (0x80040E10)
    [Microsoft][ODBC Microsoft Access Driver] For få parametere. Ventet 1.
    /ASPnettbutikk/butikk.asp, linje 137
    (too few parameters. expected 1)
    ***************
    Please use [highlight=vb] ..your code.. [/highlight] when posting code!

    When you have received the working answer to your question,
    please mark it as *SOLVED* + Your Questions Title ...using your Thread's Tool menu.


    Also try to point out what answer made it work for you, or edit your first post to contain a quote of the correct answer...

    Please Answer All Questions With Working Code Examples...


    My Unfinished Projects and My working Programs
    ***************

  6. #6

    Thread Starter
    Hyperactive Member
    Join Date
    Oct 2001
    Location
    www.alexdata.com
    Posts
    484

    Re: Can ADD and DELETE from mDB but not UPDATE..?!?!

    PS: this is the connectionstring i want to use, u used a commented out one..
    VB Code:
    1. ELSEIF Request.Form("flag")="2" THEN
    2.     SQLstmt = "UPDATE Produkter SET "
    3.     SQLstmt = SQLstmt & "Varenavn='" & TRIM(Request.Form("Varenavn")) & "', "
    4.     SQLstmt = SQLstmt & "Varenummer=" & TRIM(Request.Form("Varenummer")) & ", "
    5.     SQLstmt = SQLstmt & "Varepris=" & TRIM(Request.Form("Varepris")) & ", "
    6.     SQLstmt = SQLstmt & "Varetekst='" & TRIM(Request.Form("Varetekst")) & "', "
    7.     SQLstmt = SQLstmt & " WHERE ID=" & TRIM(Request.Form("Recordid"))
    ***************
    Please use [highlight=vb] ..your code.. [/highlight] when posting code!

    When you have received the working answer to your question,
    please mark it as *SOLVED* + Your Questions Title ...using your Thread's Tool menu.


    Also try to point out what answer made it work for you, or edit your first post to contain a quote of the correct answer...

    Please Answer All Questions With Working Code Examples...


    My Unfinished Projects and My working Programs
    ***************

  7. #7
    PowerPoster techgnome's Avatar
    Join Date
    May 2002
    Posts
    34,687

    Re: Can ADD and DELETE from mDB but not UPDATE..?!?!

    Quote Originally Posted by kaihirst
    Hi,

    right then, were getting somewhere now..

    VB Code:
    1. 'ELSEIF Request.Form("flag")="2" THEN
    2.  
    3. '    SQLstmt = "UPDATE Prices SET "
    4. '    SQLstmt = SQLstmt & "Varenavn='" & TRIM(Request.Form("Varenavn")) & "', "
    5. '    SQLstmt = SQLstmt & "Varenummer='" & TRIM(Request.Form("Varenummer")) & "', "
    6. '    SQLstmt = SQLstmt & "Varepris='" & TRIM(Request.Form("Varepris")) & "',"
    7. '    SQLstmt = SQLstmt & " WHERE_ID='" & TRIM(Request.Form("Recordid")) &"'"

    As you can see, ive made some changes to your statement.

    1. the WHERE_ID never use spaces in your tables at all. So change this for what ive substituted adn youre away.

    2. Plus you missed some single quotes out and I have added them...

    try this and see how you get on.

    Kai
    Slow down there trigger....

    The WHERE ID wasn't a FIELD name.... it was his WHERE clause. WHERE ID = 12.

    Assuming ID is in fact a number, the lack of quotes on it is correct.

    OKay... but we are getting somewhere.... Even though you've specified the table to be updated in the UPDATE clause, because you are using a WHERE clause, you have to specify the FROM caluse as well.... as silly as it seems, it should be done.

    -- strike that... I see the problem....

    VB Code:
    1. ELSEIF Request.Form("flag")="2" THEN
    2.         SQLstmt = "UPDATE Produkter SET "
    3.         SQLstmt = SQLstmt & "Varenavn='" & TRIM(Request.Form("Varenavn")) & "', "
    4.         SQLstmt = SQLstmt & "Varenummer=" & TRIM(Request.Form("Varenummer")) & ", "
    5.         SQLstmt = SQLstmt & "Varepris=" & TRIM(Request.Form("Varepris")) & ", "
    6.         SQLstmt = SQLstmt & "Varetekst='" & TRIM(Request.Form("Varetekst")) & "', " <-- see this comma right here? It shouldn't be there. Dump it.
    7.         SQLstmt = SQLstmt & " WHERE ID=" & TRIM(Request.Form("Recordid"))


    I didn't see that until I was pasting your code it... then it stood out.... The last coma after the last field being updated is not needed as there are no more fields listed after it.

    -tg
    * I don't respond to private (PM) requests for help. It's not conducive to the general learning of others.*
    * I also don't respond to friend requests. Save a few bits and don't bother. I'll just end up rejecting anyways.*
    * How to get EFFECTIVE help: The Hitchhiker's Guide to Getting Help at VBF - Removing eels from your hovercraft *
    * How to Use Parameters * Create Disconnected ADO Recordset Clones * Set your VB6 ActiveX Compatibility * Get rid of those pesky VB Line Numbers * I swear I saved my data, where'd it run off to??? *

  8. #8

    Thread Starter
    Hyperactive Member
    Join Date
    Oct 2001
    Location
    www.alexdata.com
    Posts
    484

    Smile Re: Can ADD and DELETE from mDB but not UPDATE..?!?!

    Well.. It turned out that TECHGNOME was right, but thanks for all tips and help to you other guys to, learned a lot from links and tips.. thanks

    So the right stuff looks like this
    ELSEIF Request.Form("flag")="2" THEN
    SQLstmt = "UPDATE Produkter SET "
    SQLstmt = SQLstmt & "Varenavn='" & TRIM(Request.Form("Varenavn")) & "', "
    SQLstmt = SQLstmt & "Varenummer=" & TRIM(Request.Form("Varenummer")) & ", "
    SQLstmt = SQLstmt & "Varepris=" & TRIM(Request.Form("Varepris")) & ", "
    SQLstmt = SQLstmt & "Varetekst='" & TRIM(Request.Form("Varetekst")) & "' "
    SQLstmt = SQLstmt & " WHERE ID=" & TRIM(Request.Form("Recordid"))
    ***************
    Please use [highlight=vb] ..your code.. [/highlight] when posting code!

    When you have received the working answer to your question,
    please mark it as *SOLVED* + Your Questions Title ...using your Thread's Tool menu.


    Also try to point out what answer made it work for you, or edit your first post to contain a quote of the correct answer...

    Please Answer All Questions With Working Code Examples...


    My Unfinished Projects and My working Programs
    ***************

  9. #9
    Fanatic Member kaihirst's Avatar
    Join Date
    Jul 2005
    Location
    The Resaurant At the End of The Universe
    Posts
    633

    Re: Can ADD and DELETE from mDB but not UPDATE..?!?!

    ARRGGGHH didnt look hard enough at the query!! Cheers Tech....

    Teaches me for spending 10 hours coding in the office then come straight home NOT via the pub and stright on the coding forums!!!

    NOTE TO SELF.. GET LIFE!!!!!

    Kai
    As the information I give is useful in its nature, consider using the RATE POST feature located on the bottom left of this post please..

    A few things that make a good Developer a Great One.
    Methodical and a thorough approach to research and design inevitably leads to success.
    Forward thinking is the key to Flow of control.
    Never test in the design environment, always test in real time, you get the REAL results.
    CBSE & OOSE are the same animal, they just require different techniques, and thinking.
    SEO is a globe of objectives, SE rankings is an end to a means for these objectives, not part of them.
    The key to good design is explicit attention to both detail and response.
    Think Freely out of the "Box" you're in..... You will soar to better heights.

    Kai Hirst - MSCE, MCDBA, MCSD, MCP, MCAP, MSCT


Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •  



Click Here to Expand Forum to Full Width