Wrox Programmer Forums
|
ASP.NET 2.0 Basics If you are new to ASP or ASP.NET programming with version 2.0, this is the forum to begin asking questions. Please also see the Visual Web Developer 2005 forum.
Welcome to the p2p.wrox.com Forums.

You are currently viewing the ASP.NET 2.0 Basics section of the Wrox Programmer to Programmer discussions. This is a community of software programmers and website developers including Wrox book authors and readers. New member registration was closed in 2019. New posts were shut off and the site was archived into this static format as of October 1, 2020. If you require technical support for a Wrox book please contact http://hub.wiley.com
 
Old October 14th, 2005, 04:05 AM
Friend of Wrox
 
Join Date: May 2005
Posts: 149
Thanks: 0
Thanked 0 Times in 0 Posts
Default how to verify email exists?

Hi everyone,
I have a simple question.I have the following code written.It is a simple registration form.Now how can I verify the email already exists in the database through the code?
I used do-loop in asp classic but in .net I dhave no idea.!!!


<script runat="server" language="vb">
sub insertdata(sender as object,e as eventargs)
dim strconnection as string="server=(local);database=Test;integrated security=true;"
dim objconnection as new sqlconnection(strconnection)

dim strsql as string="insert into Register(Name,Family,Tel,email,Password,Confirmpas sword)" & _
"values (@Name,@Family,@Tel,@email,@Password,@Confirmpassw ord);"
dim objcommand as new sqlcommand(strsql,objconnection)
objcommand.parameters.add("@name",sqldbtype.nvarch ar)
objcommand.parameters.add("@Family",sqldbtype.nvar char)
objcommand.parameters.add("@Tel",sqldbtype.nvarcha r)
objcommand.parameters.add("@email",sqldbtype.nvarc har)
objcommand.parameters.add("@Password",sqldbtype.nv archar)
objcommand.parameters.add("@Confirmpassword",sqldb type.nvarchar)
objcommand.parameters("@name").value=txtname.text
objcommand.parameters("@Family").value=txtfamily.t ext
objcommand.parameters("@Tel").value=txttel.text
objcommand.parameters("@email").value=txtemail.tex t
objcommand.parameters("@Password").value=txtpasswo rd.text
objcommand.parameters("@Confirmpassword").value=tx tConfirm.text
objconnection.open()
objcommand.executenonquery()
objconnection.close()
end sub
</script>

 
Old November 30th, 2009, 08:20 AM
Registered User
 
Join Date: Nov 2009
Posts: 3
Thanks: 0
Thanked 0 Times in 0 Posts
Default

Before adding txtEmail.text to SQLcommand just verify the entered text against DB like the following way

//Create function

CheckEmailAddress(txtEmail.text);

Function

public bool CheckEmailAddress(string strAddress)
{
bool Email;
//Enter SQL query like
string address = "select Emailaddress from Userprofile where Emailaddress ='" + strAddress + "';
if (address == strAddress)
{
return false;
}
else
{
return true;
}
}
-------------------------------

if (CheckEmailAddress(txtEmail.text)==true
{
//perform SQL transaction
}
else
{
//alert the user to enter another E-mail address
}





Similar Threads
Thread Thread Starter Forum Replies Last Post
Resolved! - Verify Required fields and email form dartcoach HTML Code Clinic 25 April 28th, 2008 12:48 PM
check if email account exists collie ASP.NET 2.0 Basics 2 September 13th, 2007 07:02 PM
how to verify email exists? keyvanjan ASP.NET 1.0 and 1.1 Professional 1 October 15th, 2005 12:06 PM
How to verify domain exists ? leo_vinay Classic ASP Professional 1 September 17th, 2004 04:05 AM





Powered by vBulletin®
Copyright ©2000 - 2020, Jelsoft Enterprises Ltd.
Copyright (c) 2020 John Wiley & Sons, Inc.