473,796 Members | 2,464 Online
Bytes | Software Development & Data Engineering Community
+ Post

Home Posts Topics Members FAQ

Msg is not displaying when a Enter Email that is already in Database

42 New Member
Hi All,

I Created a Registration Page with only username,Pwd,Em ail,Contactno and Address fields.

1.when a Enter user with different Email then it is saved the details in Database.

2.My Code is working fine when a Enter username with Already Existing mail id then it is not taking.But only problem is msg is not displaying client side.

How to display msg .Pls find my code also.

procedure
---------

CREATE Procedure SP_Login
(
@Username varchar(50),
@pwd varchar(50),
@Email varchar(50),
@ContactNo varchar(50),
@Address varchar(50),
@Ret_val Int = Null Out,
@Ret_msg Varchar(75) = Null Out


)
AS

IF EXISTS(SELECT * FROM Login WHERE Email=@Email)
BEGIN
RAISERROR('The email address already exists', 16, 1)

END
ELSE
BEGIN

INSERT INTO Login (Username,pwd,E mail,ContactNo, Address)VALUES( @Username,@pwd, @Email,@Contact No,@Address)

END

If @@Error = 0
BEGIN
SET @RET_VAL = 1
SET @RET_MSG = 'DETAILS INSERTED SUCCESSFULLY.'
END
ELSE
BEGIN
SET @RET_VAL = 0
SET @RET_MSG = 'ERROR : Error in Inserting Details.'
END
GO







codebehind
----------

Try
conObj = New SqlConnection(" Data Source=B4B-2F-323-CK26;user id=sa;password= sa;Database=TES T")
conObj.Open()

tranObj = conObj.BeginTra nsaction
cmdObj = conObj.CreateCo mmand
cmdObj.Transact ion = tranObj

With cmdObj
.CommandText = "SP_Login"
.CommandType = CommandType.Sto redProcedure
End With

With cmdObj.Paramete rs
.Add(New SqlParameter("@ UserName", SqlDbType.VarCh ar, 50)).Value = txtUserName.Tex t
.Add(New SqlParameter("@ pwd", SqlDbType.VarCh ar, 50)).Value = txtPwd.Text
.Add(New SqlParameter("@ ContactNo", SqlDbType.VarCh ar, 50)).Value = txtPhoneno.Text
.Add(New SqlParameter("@ Email", SqlDbType.VarCh ar, 50)).Value = txtEmail.Text
.Add(New SqlParameter("@ Address", SqlDbType.VarCh ar, 50)).Value = txtAddress.Text

retvalp = .Add("@RET_VAL" , SqlDbType.Int)
retvalp.Directi on = ParameterDirect ion.Output
retmsgp = .Add("@RET_MSG" , SqlDbType.VarCh ar, 50)
retmsgp.Directi on = ParameterDirect ion.Output


End With

cmdObj.ExecuteN onQuery()

If retvalp.Value = 1 Then
tranObj.Commit( )
lblmsg.Text = retmsgp.Value
Else
tranObj.Rollbac k()
lblmsg.Text = retmsgp.Value
End If
Catch ex As Exception
Response.Write( ex.ToString())
Finally
If Not tranObj Is Nothing Then tranObj.Dispose ()
conObj.Close()
cmdObj.Dispose( )
End Try
Mar 13 '07 #1
1 1095
kenobewan
4,871 Recognized Expert Specialist
The raiseerror only throws an sqlexception. Here is an interesting way to catch it using infomessage handler:
Getting Intimate with your Connection
Mar 13 '07 #2

Sign in to post your reply or Sign up for a free account.

Similar topics

1
2272
by: Yoshitha | last post by:
hi I have datalist control in my ASP.NET application the problem here is i have used a textbox with multiline true propertly when i enter data like "fdjsfhjksdhfjsdfhsdjhfsdfhsdjfhsd jfdsjfksdjfksdjkfjsdfjksdjfsdjfd fdsfhjsdhfjsdhfjf dsjf dsjfhjsdfhjksdh d fdsjf hsdjkfhdjsfhsdjfh ds
0
1831
by: WindAndWaves | last post by:
Hi Gurus Here is another question that I have been struggling with for over a year. Basically, I would like to allow users to enter data into three tables in at the same time. The reason it should all be happening on one form is that the data comes in in chuncks and that the users do not like switching between windows (forms) too many times. To enter data into two tables (e.g. organisations and contacts) at the same
5
3073
by: Helen | last post by:
Hi I'm using ASP.NET's standard validators to display error messages when people don't fill in required fields on my form. The error messages currently show as soon as the form is loaded, but what I'd really like is for the error messages to only be displayed after the validation fails. Is this a feature of the standard ASP.NET validation or will I have to write custom validators if I want to do that?
1
1230
by: Yoshitha | last post by:
Hi I have datalist control in my ASP.NET application the problem here is i have used a textbox with multiline true propertly when i enter data like "fdjsfhjksdhfjsdfhsdjhfsdfhsdjfhsd jfdsjfksdjfksdjkfjsdfjksdjfsdjfd fdsfhjsdhfjsdhfjf dsjf dsjfhjsdfhjksdh d fdsjf hsdjkfhdjsfhsdjfh ds
13
2903
by: David W. Fenton | last post by:
I've been struggling the last two days with something I thought was very easy, which is to open a web page with a form on it and populate the form with data passed in a query string (either POST or GET). I got Application.FollowHyperlink *kind* of working, but was having problem with double encoding of some characters (I had to do special things with + signs in the data, as well as never figuring out why some data was getting...
3
1615
by: limperger | last post by:
Hello everyone: This question is neither urgent nor important, but I post it just in case anyone knows (and wants to give a reply, of course XD). I have little idea of VBA, but I have dared to write a little piece of code. It is as follows: Private Sub Comando551_Click() Dim qry As String qry = "BUSQUEDA PACIENTES" DoCmd.OpenQuery qry If . Is Not Null Then MsgBox ("This person is present in the DB")
1
2383
by: robin1983 | last post by:
Dear All, I got stuck in simple problem, I have a two php file one for registration form and one for to check and insert into the table. The problem is that when I get any kind error in validiation the code is working properly but when the condition are fulfilled the code inside the if part is not executing. The following is the code for registration form UserAdd.php <html xmlns="http://www.w3.org/1999/xhtml"> <head> <meta...
7
6672
by: RichB | last post by:
I am trying to get to grips with the asp.net ajaxcontrol toolkit, and am trying to add a tabbed control to the page. I have no problems within the aspx file, and can dynamically manipulate a tabcontainer which has 1 panel already, however I want to try create the TabPanels dynamically. I followed the advice here: http://www.asp.net/learn/ajax-videos/video-156.aspx (3rd comment - Joe Stagner)
10
6982
by: happyse27 | last post by:
Hi All, I got this apache errors(see section A1 and A2 below) when I used a html(see section b below) to activate acctman.pl(see section c below). Section D below is part of the configuration of section c. Not sure where went wrong as the web page displayed internal server error. Also, what is the error 543? and error 2114. Where to find the list of errors in websites as it is not the standard apache error. I could not find...
0
9680
marktang
by: marktang | last post by:
ONU (Optical Network Unit) is one of the key components for providing high-speed Internet services. Its primary function is to act as an endpoint device located at the user's premises. However, people are often confused as to whether an ONU can Work As a Router. In this blog post, we’ll explore What is ONU, What Is Router, ONU & Router’s main usage, and What is the difference between ONU and Router. Let’s take a closer look ! Part I. Meaning of...
0
10456
Oralloy
by: Oralloy | last post by:
Hello folks, I am unable to find appropriate documentation on the type promotion of bit-fields when using the generalised comparison operator "<=>". The problem is that using the GNU compilers, it seems that the internal comparison operator "<=>" tries to promote arguments from unsigned to signed. This is as boiled down as I can make it. Here is my compilation command: g++-12 -std=c++20 -Wnarrowing bit_field.cpp Here is the code in...
0
10012
tracyyun
by: tracyyun | last post by:
Dear forum friends, With the development of smart home technology, a variety of wireless communication protocols have appeared on the market, such as Zigbee, Z-Wave, Wi-Fi, Bluetooth, etc. Each protocol has its own unique characteristics and advantages, but as a user who is planning to build a smart home system, I am a bit confused by the choice of these technologies. I'm particularly interested in Zigbee because I've heard it does some...
0
9052
agi2029
by: agi2029 | last post by:
Let's talk about the concept of autonomous AI software engineers and no-code agents. These AIs are designed to manage the entire lifecycle of a software development project—planning, coding, testing, and deployment—without human intervention. Imagine an AI that can take a project description, break it down, write the code, debug it, and then launch it, all on its own.... Now, this would greatly impact the work of software developers. The idea...
1
7548
isladogs
by: isladogs | last post by:
The next Access Europe User Group meeting will be on Wednesday 1 May 2024 starting at 18:00 UK time (6PM UTC+1) and finishing by 19:30 (7.30PM). In this session, we are pleased to welcome a new presenter, Adolph Dupré who will be discussing some powerful techniques for using class modules. He will explain when you may want to use classes instead of User Defined Types (UDT). For example, to manage the data in unbound forms. Adolph will...
0
5442
by: TSSRALBI | last post by:
Hello I'm a network technician in training and I need your help. I am currently learning how to create and manage the different types of VPNs and I have a question about LAN-to-LAN VPNs. The last exercise I practiced was to create a LAN-to-LAN VPN between two Pfsense firewalls, by using IPSEC protocols. I succeeded, with both firewalls in the same network. But I'm wondering if it's possible to do the same thing, with 2 Pfsense firewalls...
0
5575
by: adsilva | last post by:
A Windows Forms form does not have the event Unload, like VB6. What one acts like?
2
3731
muto222
by: muto222 | last post by:
How can i add a mobile payment intergratation into php mysql website.
3
2926
bsmnconsultancy
by: bsmnconsultancy | last post by:
In today's digital era, a well-designed website is crucial for businesses looking to succeed. Whether you're a small business owner or a large corporation in Toronto, having a strong online presence can significantly impact your brand's success. BSMN Consultancy, a leader in Website Development in Toronto offers valuable insights into creating effective websites that not only look great but also perform exceptionally well. In this comprehensive...

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.