hello !

I'm working on a Registry page for my webSite in ASP and I'm trying to get results of a prcedure from my database which is checking if there is any duplicates of loginNames or emails when there is inserting to Dbase. The problem is I can't finde any functions to get this results in asp.ne/C#t. Have any one such a problem, or knows how to do this ? Thanks for any help.

Recommended Answers

All 2 Replies

Are you having trouble with the SQL query to check if the name is already used?
just do a SELECT COUNT() on the user name or email. There should be zero results if the name is unique and 1 if it is already registered. You can then proceed to save the user's details or inform them that the name is taken.

u can also do a select query with ur username and email in where condition and then if the reader is true then set the msg as already exists or allow the user for registration....

Below code is just to present u an idea....

 Try
    Dim MySQL_Connection As SqlConnection = New SqlConnection()
    MySQL_Connection.ConnectionString = "Data Source = LocalHost;Initial Catalog = database;Integrated Security  = True"
    MySQL_Connection.Open()
    Dim mysqlCommand As SqlCommand
    mysqlCommand = New SqlCommand("SELECT PATIENT_ID FROM Patient_Reg WHERE PATIENT_ID='" + txtPatientID.Text + "'", MySQL_Connection)
    Dim DBReader As SqlDataReader = mysqlCommand.ExecuteReader
    If DBReader.Read = True Then
       Msgbox("patient already exists")
    else
        'insert query
    End If
Catch ex As Exception
    Msgbox(ex.message)                
End Try
Be a part of the DaniWeb community

We're a friendly, industry-focused community of developers, IT pros, digital marketers, and technology enthusiasts meeting, networking, learning, and sharing knowledge.