Validation of email address when user registers...how?

Posted by Paprikano under VB.NET on 8/20/2012 | Points: 10 | Views : 2720 | Status : [Member] | Replies : 9
Guys how do I checks if an email address already exists on the system/database when a user is registering, but I am using a stored procedure to insert all my records, but I'm lost as to where I
write this functionality to do the checking of emails if they already exists.




Responses

Posted by: Gopesh9 on: 8/20/2012 [Member] Starter | Points: 25

Up
0
Down
You can create that EmailID column in your database as Unique, so that whenever any duplicatevalue is inserted you can catch the exception from the database and can told the user that this EmailID is already registered or you have to check all the rows of the database to check that the emailID is nique or not...

G. S.
.Net Developer

Paprikano, if this helps please login to Mark As Answer. | Alert Moderator

Posted by: Suryabalan on: 8/20/2012 [Member] Starter | Points: 25

Up
0
Down
Thank u...............

Paprikano, if this helps please login to Mark As Answer. | Alert Moderator

Posted by: Srilu.Nayini577 on: 8/20/2012 [Member] Starter | Points: 25

Up
0
Down
create mailid column in database.You can use following .net through ado.net
Declare connectionobj;
Declare commandobj;

string s=select count(*) from tablename where mailid=textbox1.text;
int i=(int)cmd.executeReader();
if(i==1)
mesageBox.show("mailid already exists);
else
mesageBox.show("mailid inserted etc..);

SRILATHA
.Net Developer

Paprikano, if this helps please login to Mark As Answer. | Alert Moderator

Posted by: Eni on: 8/21/2012 [Member] Starter | Points: 25

Up
0
Down
U can try this for checking the e-mail address alredy exists or not???


SqlConnection cn = new SqlConnection(ConfigurationManager.ConnectionStrings["...."].ConnectionString);

cn.Open();
string query = "select ......'";
SqlCommand cmd = new SqlCommand(query, cn);

string email = cmd.ExecuteScalar().ToString();

cn.Close();
if (email == "0")
{
Label1.Text = "available";
}
else
{
Label1.Text = "Not Available";

}


Will Work i think so.....



with regards,
eni.


Paprikano, if this helps please login to Mark As Answer. | Alert Moderator

Posted by: Srilu.Nayini577 on: 8/21/2012 [Member] Starter | Points: 25

Up
0
Down
No.Please check my code it will works.

If(i==1) means the query returns 1,If email already exists only the query returns 1.i.e,count(*)=1

So please check properly.

Thank you,

SRILATHA
.Net Developer

Paprikano, if this helps please login to Mark As Answer. | Alert Moderator

Posted by: Paprikano on: 10/26/2012 [Member] Starter | Points: 25

Up
0
Down
Srilu.Nayini577 UR CODE DOES NOT WORK, int i=(int)cmd.executeReader(); GIVES errors about invalid input string
int i=(int)cmd.ExecuteScalar(); gives erros abt The multi-part identifier "email@email.com" could not be bound.


Paprikano, if this helps please login to Mark As Answer. | Alert Moderator

Posted by: Jayakumars on: 10/26/2012 [Member] [MVP] Bronze | Points: 25

Up
0
Down
hi to all

check this

http://www.dotnetfunda.com/codes/code3247-how-to-save-valid-and-invalid-email-id-using-stored-procedure.aspx

if this helps please mark as answer

Mark as Answer if its helpful to you

Kumaraspcode2009@gmail.com

Paprikano, if this helps please login to Mark As Answer. | Alert Moderator

Posted by: Vinay13mar on: 11/25/2012 [Member] Starter | Points: 25
Posted by: Paprikano on: 4/5/2013 [Member] Starter | Points: 25

Up
0
Down
Thanks to you all,
in the end I used
string email="select emailAddress from tablename where emailAddress=' " + txtEmailaddress.text + " ' ";
this code is inside a bool type method, and i check if it returns true or false.

Paprikano, if this helps please login to Mark As Answer. | Alert Moderator

Login to post response