Update(asp)

Results 1 to 2 of 2

Thread: Update(asp)

  1. #1
    Mezaache Guest

    Default Update(asp)

    I ve got this error when I used a form where the user entr some inf , and click updae his info with db access.<BR>General error Unable to open registry key &#039DriverId&#039. <BR>My code is:<BR><BR>QLstmt = "UPDATE AE "<BR>SQLStmt = SQLstmt & "SET LASTNAME=&#039"& Request.QueryString("name") & "&#039,"<BR>SQLStmt = SQLStmt & " WHERE FIRSTNAME=" & Request.QueryString("name")<BR>Set RS = Conn.Execute(SQLStmt)

  2. #2
    Join Date
    Dec 1969
    Posts
    1,315

    Default RE: Update(asp)

    Here are some of the errors I noticed:<BR>1. In line 2, you shouldn&#039t include a comma (,).<BR> It is used when you want to update more than one fields.<BR> In your case you only want to edit the data in the lastname<BR> field.<BR> So, the correct one is:<BR>SQLStmt = SQLStmt & "SET LASTNAME=&#039" & Request.QueryString("name") & "&#039"<BR><BR>2. Request.QueryString("name") is equivalent to a string <BR> variable. So, you need to include the single apostrophes<BR> in line 3. So, you would write:<BR>SQLStmt = SQLStmt & " WHERE FIRSTNAME=&#039" & Request.QueryString("name") & "&#039"<BR><BR>3. Logical error:<BR>What you are trying to do is to replace the lastname with its firstname.<BR>Let&#039s say, my firstname is: John<BR> my lastname is: Weeflaar<BR>After updating, it will be:<BR> my firstname is: John<BR> my lastname is: John<BR><BR>So, you actually need 2 input texts. One for fname, the other is<BR>for lname. <BR>Then, you assign the LASTNAME field to Request.QueryString("lname")<BR>and<BR>FIRSTNAME field to Request.QueryString("fname")<BR><BR>The risk is there are more than one John,<BR>so, two different (if there are only 2 in the table) Johns:<BR>John Weeflaar<BR>John Dalton<BR><BR>will have their lastnames updated with the word you want.<BR><BR>Hope this makes sense.<BR><BR>Regards,<BR><BR>John Weeflaar<BR><BR>

Posting Permissions

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