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.

Edited by hatebin

5 Years
Discussion Span
Last Post by poojavb

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....

    Dim MySQL_Connection As SqlConnection = New SqlConnection()
    MySQL_Connection.ConnectionString = "Data Source = LocalHost;Initial Catalog = database;Integrated Security  = True"
    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")
        'insert query
    End If
Catch ex As Exception
End Try

Edited by poojavb

This topic has been dead for over six months. Start a new discussion instead.
Have something to contribute to this discussion? Please be thoughtful, detailed and courteous, and be sure to adhere to our posting rules.