|
 |
asp_databases thread: Duplicate Records
Message #1 by "craig" <cn60@m...> on Mon, 12 Aug 2002 18:58:44
|
|
Below is code to take user information and place it in an access 2000
database. Everything works fine. but 2 questions i have how do i stop
duplicate emails from being entered and how do i validate those emails
are accurate. this is my first attempt at this, i have read some articles
but it is a little over nmy head at this point, any advice would be
helpful.
thanks,
craig
<%
IF request.form ("Message")="True" THEN
strTB1=request.form("FirstTextBox")
strTB2=request.form("SecondTextBox")
strTB3=request.form("EMail")
'Opening the DataBase Object
set objConn = server.createobject("ADODB.Connection")
objConn.Open "DSN=info"
set cm = Server.CreateObject("ADODB.Command")
cm.ActiveConnection = objConn
cm.CommandText ="INSERT INTO SampleDb(TB1,TB2,TB3) VALUES (?,?,?)"
'First Text Box Parameter Statement
set objparam=cm.createparameter(, 200, , 255, strTB1)
cm.parameters.append objparam
'Second Text Box Parameter Statement
set objparam=cm.createparameter(, 200, , 255, strTB2)
cm.parameters.append objparam
'Third Text Box Value Parameter Statement
set objparam=cm.createparameter(, 200, , 255, strTB3)
cm.parameters.append objparam
cm.execute
response.write("Thank you!")
ELSE%>
Message #2 by "Jack Dunstan" <jdunstan7@h...> on Mon, 12 Aug 2002 14:18:18 -0400
|
|
Craig,
What's the structure of the table you have set up in your Access 2000? In
other words, do you have a primary key set, for example
Your Table name: MyEmailNames
EmailID - text
FirstName - text
LastName - text
EmailID<-- you can make this the primary key so craig@h... , craig,
craiglastname would be one row, if you tried to enter craig@h...,
craig, craignewlastname - would be rejected becaue of the primary key
constraint, but craig1@h... , blah, blah would work.
hth
Jack
----- Original Message -----
From: "craig" <cn60@m...>
To: "ASP Databases" <asp_databases@p...>
Sent: Monday, August 12, 2002 6:58 PM
Subject: [asp_databases] Duplicate Records
> Below is code to take user information and place it in an access 2000
> database. Everything works fine. but 2 questions i have how do i stop
> duplicate emails from being entered and how do i validate those emails
> are accurate. this is my first attempt at this, i have read some articles
> but it is a little over nmy head at this point, any advice would be
> helpful.
> thanks,
> craig
>
>
>
> <%
> IF request.form ("Message")="True" THEN
> strTB1=request.form("FirstTextBox")
> strTB2=request.form("SecondTextBox")
> strTB3=request.form("EMail")
>
>
> 'Opening the DataBase Object
> set objConn = server.createobject("ADODB.Connection")
> objConn.Open "DSN=info"
> set cm = Server.CreateObject("ADODB.Command")
> cm.ActiveConnection = objConn
>
> cm.CommandText ="INSERT INTO SampleDb(TB1,TB2,TB3) VALUES (?,?,?)"
>
>
> 'First Text Box Parameter Statement
> set objparam=cm.createparameter(, 200, , 255, strTB1)
> cm.parameters.append objparam
>
> 'Second Text Box Parameter Statement
> set objparam=cm.createparameter(, 200, , 255, strTB2)
> cm.parameters.append objparam
>
> 'Third Text Box Value Parameter Statement
> set objparam=cm.createparameter(, 200, , 255, strTB3)
> cm.parameters.append objparam
>
>
>
>
>
> cm.execute
> response.write("Thank you!")
> ELSE%>
>
|
|
 |