Answered step by step
Verified Expert Solution
Link Copied!

Question

1 Approved Answer

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.

image text in transcribed

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

Step: 1

blur-text-image

Get Instant Access to Expert-Tailored Solutions

See step-by-step solutions with expert insights and AI powered tools for academic success

Step: 2

blur-text-image_2

Step: 3

blur-text-image_3

Ace Your Homework with AI

Get the answers you need in no time with our AI-driven, step-by-step assistance

Get Started

Recommended Textbook for

Distributed Relational Database Architecture Connectivity Guide

Authors: Teresa Hopper

4th Edition

0133983064, 978-0133983067

More Books

Students also viewed these Databases questions

Question

=+ Are there additional forms of employee representation?

Answered: 1 week ago

Question

=+What is the nature of their impact?

Answered: 1 week ago

Question

=+Is it possible to operate union-free?

Answered: 1 week ago