Skip to main content
Known Participant
March 13, 2010
Answered

search record in database to update - asp

  • March 13, 2010
  • 1 reply
  • 5685 views

Hi,

I need help with searching for a value in the database (i.e. email address) so the user can update or delete their records.

I have no trouble updating. I usually list the data and then click on the one that needs updating.

I'm having trouble retrieving the information after the user has typed in their email address.

Here is my code so far - at the moment I have listed the data in a table with an "update" link next to each row that allows me to update.

Where would I put the text field where the user can type in their email? I've tried different ways but was unsuccessful.

<input name="email" type="text" id="email" size="50">

Hope you can help

Thanks

<%

.

.

.

.

strSQL = "SELECT * FROM emails"

rsEmail.Open strSQL, conn

%>

<html>

<head><title>All</title><meta http-equiv="Content-Type" content="text/html; charset=UTF-8">

<link href="layout.css" rel="stylesheet" type="text/css">

</head>

<body>

<div id="wrapper">

  <p>  </p>

  <div id="view">

  <div class="insert"><a href="insertform.html">Insert</a></div>

  </div>

  <table width="1100" cellpadding="5">

    <tr>

      <td width="53">ID</td>

      <td width="300">firstname</td>

      <td width="378">lastname</td>

      <td width="121">email</td>

      <td width="92">Update</td>

      <td width="92">Delete</td>

    </tr>

  </table>

  <table width="1100" cellpadding="5">

    <%

   Do While not rsEmail.EOF

%>

    <tr><td width="53"><% Response.Write rsEmail("id") %></td>

      <td width="294"><% Response.Write rsEmail("firstname") %></td>

      <td width="374"><% Response.Write rsEmail("lastname") %></td>

      <td width="119"><% Response.Write rsEmail("email") %></td>

      <td width="91"><%  Response.Write ("<a href=""update_form.asp?ID=" & rsEmail("ID") & """>")%>Update<%Response.Write ("</a>") %></td>

    </tr>

    <%

rsEmail.MoveNext

Loop

'Reset server objects

rsEmail.Close

Set rsEmail = Nothing

Set conn = Nothing

%>

  </table>

</div>

</body>

</html>

(i rephrased my question earlier but the views were the same so I thought I should re-post my new quesion as I am really struggling! ) hope someone can help!

Thank you

This topic has been closed for replies.
Correct answer bregent

Thank you for your reply. I tried search = Request.Querystring("email") and I got the following error message: -

Microsoft OLE DB Provider for SQL Server error '80040e14'

The multi-part identifier "test@email.com" could not be bound.

/1one/test/update_form2.asp, line 29

This is what is passed in the url: -

/update_form2.asp?email=test%email.com

(I know test@email.com is in the database)

Line 29 is

rsMenu.Open strSQL, conn

Any ideas?


strSQL = "SELECT * FROM emails WHERE email=" & search

The parameter in the where clause of your select statment should be wrapped within quotes. Try this:

strSQL = "SELECT * FROM emails WHERE email='" & search & "'"

1 reply

Participating Frequently
March 13, 2010

>I'm having trouble retrieving the information

>after the user has typed in their email address.

Please explain the desired workflow. It sounds like you want a user to be able to search and then update a record. Is that correct? What records are they allowed to update? Do they need to already be logged in. We need a more complete picture to offer possible solutions.

dips045Author
Known Participant
March 13, 2010

Hi

I have a database of clients and to keep it up to date, we will be sending out an email asking them to confirm if they're details are correct and up to date. Details like Name telephone and address etc (just personal details)

In that email will be a link to a webpage where they can confirm their details are up to date. They will have to type in their email address (so this is kind of like the login) which will then retrieve their information to update or confirm they are correct.

But yes, the user will need to type in their email address to update the record.

Retrieving the users information from the email typed in is what I'm having trouble with.

Hope that makes sense - hope you can help.

Thanks

Participating Frequently
March 14, 2010

Have you looked at any of the tutorials for using DW to create search/result pages?

You can try these:

http://www.adobe.com/support/dreamweaver/programs/mx_search/mx_search02.html

http://www.sebastiansulinski.co.uk/tutorials/show_item/40/display_search_result

However, what you are attempting could be considered dangerous as you are allowing unauthenticated users to modify data on your site and possibly gain access to sensitive customer data.