Hi

I've written this code (that works) to inserts registration details into an Access 2010 DB from an aspx registration page.

How do I check for duplicates Email before inserting a new record into the DB

Dim strConn As String = "Provider=Microsoft.ACE.OLEDB.12.0;Data Source=C:\InetPub\WWWRoot\BushHouseGibraltar\Bush.accdb;Persist Security Info=False;"

 Dim MySQL As String = "INSERT INTO Reg " & _
            "(Email,Title,FirstName,LastName,Address1,Address2,City,Phone) VALUES " & _
            "('" & EmailAddress.Text & "','" & DropDownList1.Text & "','" _
            & FirstName.Text & "','" & LastName.Text & "','" _
            & Address1.Text & "','" & Address2.Text & "','" _
            & City.Text & "','" & Phone.Text & "')"

            Dim MyConn As New Data.OleDb.OleDbConnection(strConn)
            Dim cmd As New Data.OleDb.OleDbCommand(MySQL, MyConn)
            MyConn.Open()
            cmd.ExecuteNonQuery()


        MyConn.Close()

Thanks
ViRiPuFF

Make that column unique in database, when you try to insert duplicate email it will give you error. So handle that error and give message to user.

first generate Select query for getting rows of checking Exist Email from your databse
like 'Select EmailId from table where EmailID='EmailAddress.Text'

and if exist then show alert else insert your data

Thanks

I try this out this evening at the momemnt I am on a 15 min break from work. Thanks again.

ViRiPuFF