Wrox Home  
Search P2P Archive for: Go

  Return to Index  

asp_databases thread: Preventing duplicate records from database


Message #1 by "Ben Miller" <ben@m...> on Thu, 24 Jan 2002 11:30:41 -0600
Hello,



I've created a form that reads its field values from a SQL database.

However, many of the entries in the SQL table have duplicate data in

specific fields. Does anyone have any clues as to how to filter for

duplicate data when reading from the database?



Thanks very much,

Ben





Message #2 by dont worry <aspmailbox@y...> on Thu, 24 Jan 2002 09:47:38 -0800 (PST)
You can have "pre" query.  Query the database for the

duplicate item and if it is EOF then there is no item

and you can do the insert.  

Thats 1 way to do it

DW

--- Ben Miller <ben@m...> wrote:

> Hello,

> 

> I've created a form that reads its field values from

> a SQL database.

> However, many of the entries in the SQL table have

> duplicate data in

> specific fields. Does anyone have any clues as to

> how to filter for

> duplicate data when reading from the database?

> 

> Thanks very much,

> Ben

> 

> 

> 





$subst('Email.Unsub').





__________________________________________________

Do You Yahoo!?

Great stuff seeking new owners in Yahoo! Auctions! 

http://auctions.yahoo.com

Message #3 by "Drew, Ron" <RDrew@B...> on Thu, 24 Jan 2002 13:26:44 -0500
Agree...I use  ...I reduced the number of parameters to shorten the

display

  if objRS.EOF then

        set objRS =3D Nothing

	    set objCommand =3D Server.CreateObject("ADODB.Command")

        objCommand.ActiveConnection =3D objConn

  

        strSQL =3D "INSERT INTO mytable (Name)" &_

                 " VALUES (?)"

        objCommand.CommandText =3D strSQL

  

        objCommand.Parameters.Append

objCommand.CreateParameter("Name",200, ,30)

        objCommand("Name") =3D sName

        objCommand.Execute

        set objCommand =3D Nothing

        scrMsg =3D "<b>Name: " & sName & "<br>" &_

           "<strong><hr><p><br><br>HAS BEEN ADDED TO mytable" &_

           "<strong><p>Thank you"

        Response.Write scrMsg  

   else

        scrMsg =3D "<br><p><b>The Entry for..." & sName &_

        "<hr><br><br>is already exists."

        Response.Write scrMsg

   end if



-----Original Message-----

From: dont worry [mailto:aspmailbox@y...]

Sent: Thursday, January 24, 2002 12:48 PM

To: ASP Databases

Subject: [asp_databases] Re: Preventing duplicate records from database





You can have "pre" query.  Query the database for the

duplicate item and if it is EOF then there is no item

and you can do the insert. 

Thats 1 way to do it

DW

--- Ben Miller <ben@m...> wrote:

> Hello,

>

> I've created a form that reads its field values from

> a SQL database.

> However, many of the entries in the SQL table have

> duplicate data in

> specific fields. Does anyone have any clues as to

> how to filter for

> duplicate data when reading from the database?

>

> Thanks very much,

> Ben

>

>

>





$subst('Email.Unsub').





__________________________________________________

Do You Yahoo!?

Great stuff seeking new owners in Yahoo! Auctions!

http://auctions.yahoo.com






$subst('Email.Unsub').

Message #4 by "Simon Barnett" <si@a...> on Fri, 25 Jan 2002 01:31:48 -0000
I used it myself for the same reason.



rsString = "SELECT DISTINCT  db_Field FROM  assets"





Simon



----- Original Message -----

From: "Ben Miller" <ben@m...>

To: "ASP Databases" <asp_databases@p...>

Sent: Thursday, January 24, 2002 5:30 PM

Subject: [asp_databases] Preventing duplicate records from database





> Hello,

>

> I've created a form that reads its field values from a SQL database.

> However, many of the entries in the SQL table have duplicate data in

> specific fields. Does anyone have any clues as to how to filter for

> duplicate data when reading from the database?

>

> Thanks very much,

> Ben

>

>

>




$subst('Email.Unsub').



Message #5 by "Ben Miller" <ben@m...> on Thu, 24 Jan 2002 21:34:21 -0600
Thanks to Simon, Ron, and DW for your able help.



In the case of the particular database fields I'm working with, I used

the DISTINCT condition Simon mentioned, but also had to close and then

reopen the database for each instance of a field where the form field

derives its contents.



Cheers,

Ben 







> -----Original Message-----

> From: Simon Barnett [mailto:si@a...] 

> Sent: Thursday, January 24, 2002 7:32 PM

> To: ASP Databases

> Subject: [asp_databases] Re: Preventing duplicate records 

> from database

> 

> 

> I used it myself for the same reason.

> 

> rsString = "SELECT DISTINCT  db_Field FROM  assets"

> 

> 

> Simon

> 

> ----- Original Message -----

> From: "Ben Miller" <ben@m...>

> To: "ASP Databases" <asp_databases@p...>

> Sent: Thursday, January 24, 2002 5:30 PM

> Subject: [asp_databases] Preventing duplicate records from database

> 

> 

> > Hello,

> >

> > I've created a form that reads its field values from a SQL 

> database. 

> > However, many of the entries in the SQL table have 

> duplicate data in 

> > specific fields. Does anyone have any clues as to how to filter for 

> > duplicate data when reading from the database?

> >

> > Thanks very much,

> > Ben

> >

> >

> >

> > ---

> > Change your mail options at http://p2p.wrox.com/manager.asp or to 

> > unsubscribe send a blank email to

> $subst('Email.Unsub').

> 

> 




> $subst('Email.Unsub').

> 

> 






  Return to Index