Question: How to check if username already exists in SQL Database from Asp. The program I am writing is a register form and it works, I
How to check if username already exists in SQL Database from Asp.
The program I am writing is a register form and it works, I just need to refine it to specific details. I need to write in apsx.cs on how to check the database if the username(Email) has already been used for the register.

The above code does work, it adds information to the database table that I have. But I just need to write something that lets me know that the username has already been used.
//registration function protected void registerUser (Object src, EventArgs e) 98 100 101 102 Response.Write( "you have connected to your .cs page add records"); get_connection); try 104 105 106 107 108 109 110 connection.Open); commandnew SqlCommand ("INSERT INTO subscribers (FirstName, LastName, Email, Password)" VALUES (@FirstName, ELastName, @Email, Password)", connection); command.Parameters. AddwithValue("@FirstName", txtFirstName.Text) command.Parameters.AddwithValue("@LastName", txtlastName.Text); command.Parameters. AddWithValue("@Email", txtFmail.Text); command.Parameters.AddwithValue("@Password", txtPassword.Text); 112 113 114 115 116 command.ExecuteNonQuery); connection.Close); catch(Exception err) 118 119 120 121 122 123 124 125 126 127 128 129 13e 131 132 IblInfo.Text"Error reading the database. " 1blInfo . Text += err-Message; finally connection.Close); 1blInfo. Text +- "
Record has been added"; //1blInfo.Textb>Server Version: "connection.ServerVersion; lbllnfo . Text +--
Connection 15%/b> + connection . State. Tost ring()
Step by Step Solution
There are 3 Steps involved in it
Get step-by-step solutions from verified subject matter experts
