Wrox Programmer Forums
|
ASP.NET 1.0 and 1.1 Professional For advanced ASP.NET 1.x coders. Beginning-level questions will be redirected to other forums. NOT for "classic" ASP 3 or the newer ASP.NET 2.0 and 3.5
Welcome to the p2p.wrox.com Forums.

You are currently viewing the ASP.NET 1.0 and 1.1 Professional 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 15th, 2005, 02:01 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 October 15th, 2005, 12:06 PM
Imar's Avatar
Wrox Author
 
Join Date: Jun 2003
Posts: 17,089
Thanks: 80
Thanked 1,576 Times in 1,552 Posts
Default

What you could do is execute a SELECT statement that either returns a record, or a number indicating the number of records with the same e-mail address.

Something like this:

SELECT COUNT(EmailAddress) FROM MyTable WHERE EmailAddress = 'Email'

Then you can use ExecuteScalar of your SqlCommand object which returns this number and cast it to an Integer. When it's 0, the email address doesn't exist.

HtH,

Imar
---------------------------------------
Imar Spaanjaars
Everyone is unique, except for me.





Similar Threads
Thread Thread Starter Forum Replies Last Post
how to verify email exists? keyvanjan ASP.NET 2.0 Basics 1 November 30th, 2009 08:20 AM
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 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.