|
| |
|
|
hawleyr
Posts: 21 Joined: 8/24/2007 Status: offline
|
Preventing Duplicate Entries in Access via ASP - 9/16/2009 11:55:39
I used the suggested page http://www.aspfaqs.com/aspfaqs/ShowFAQ.asp?FAQID=106 to help me out on my problem; however, I'm still getting and error. I think I may have misplaced a line of code. Could anyone give me a hand? My current form posts to this asp page: <%
'Dimension variables
Dim adoCon 'Holds the Database Connection Object
Dim rsAddComments 'Holds the recordset for the new record to be added
Dim strSQL 'Holds the SQL query to query the database
'Create an ADO connection object
Set adoCon = Server.CreateObject("ADODB.Connection")
'Set an active connection to the Connection object using a DSN-less connection
adoCon.Open "Provider=Microsoft.Jet.OLEDB.4.0; Data Source=" & Server.MapPath("../fpdb/ResourceRequest2008.mdb")
'Create an ADO recordset object
Set rsAddComments = Server.CreateObject("ADODB.Recordset")
'Initialise the strSQL variable with an SQL statement to query the database
strSQL = "SELECT Investigator.First_Name, Investigator.Last_Name, Investigator.Institution, Investigator.Department, Investigator.Street1, Investigator.Street2, Investigator.City, Investigator.State, Investigator.Postal_Code, Investigator.Country, Investigator.Phone, Investigator.Fax, Investigator.Email, Investigator.Inserted_Date FROM Investigator WHERE Email = '" & _
Request.Form("Email") & "'"
Set rs = db.Execute()
If rs.EOF Then
'Set the cursor type we are using so we can navigate through the recordset
rsAddComments.CursorLocation = 3
rsAddComments.CursorType = 2
'Set the lock type so that the record is locked by ADO when it is updated
rsAddComments.LockType = 3
'Open the recordset with the SQL query
rsAddComments.Open strSQL, adoCon
'Tell the recordset we are adding a new record
rsAddComments.AddNew
'Add a new record to the recordset
rsAddComments.Fields("First_Name") = Request.Form("First_Name")
rsAddComments.Fields("Last_Name") = Request.Form("Last_Name")
rsAddComments.Fields("Institution") = Request.Form("Institution")
rsAddComments.Fields("Department") = Request.Form("Department")
rsAddComments.Fields("Street1") = Request.Form("Street1")
rsAddComments.Fields("Street2") = Request.Form("Street2")
rsAddComments.Fields("City") = Request.Form("City")
rsAddComments.Fields("State") = Request.Form("State")
rsAddComments.Fields("Postal_Code") = Request.Form("Postal_Code")
rsAddComments.Fields("Country") = Request.Form("Country")
rsAddComments.Fields("Phone") = Request.Form("Phone")
rsAddComments.Fields("Fax") = Request.Form("Fax")
rsAddComments.Fields("Email") = Request.Form("Email")
' Insert User IP address
'rsAddComments.Fields("UserIP") = request.ServerVariables("REMOTE_HOST")
' Insert the current time
rsAddComments.Fields("Inserted_Date") = Date()
'Write the updated recordset to the database
rsAddComments.Update
'Reset server objects
rsAddComments.Close
Set rsAddComments = Nothing
Set adoCon = Nothing
Else
Response.Write "Record exists"
End If
%> When the form posts I get: Microsoft VBScript runtime error '800a01a8' Object required: 'db' /ResourceDB/Investigator_Add.asp, line 20 Line 20 of the code is: Set rs = db.Execute() I'm also concerned my final lines of code for response.write is in the wrong place. Thank you for any help!
|
|
|
|
hawleyr
Posts: 21 Joined: 8/24/2007 Status: offline
|
RE: Preventing Duplicate Entries in Access via ASP - 9/16/2009 15:21:03
*smacks forehead* Thanks!
|
|
New Messages |
No New Messages |
Hot Topic w/ New Messages |
Hot Topic w/o New Messages |
Locked w/ New Messages |
Locked w/o New Messages |
|
Post New Thread
Reply to Message
Post New Poll
Submit Vote
Delete My Own Post
Delete My Own Thread
Rate Posts
|
|
|