Wrox Programmer Forums
Go Back   Wrox Programmer Forums > SQL Server > SQL Server 2000 > SQL Server 2000
| Search | Today's Posts | Mark Forums Read
SQL Server 2000 General discussion of Microsoft SQL Server -- for topics that don't fit in one of the more specific SQL Server forums. version 2000 only. There's a new forum for SQL Server 2005.
Welcome to the p2p.wrox.com Forums.

You are currently viewing the SQL Server 2000 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 April 15th, 2005, 02:54 PM
Authorized User
 
Join Date: Jun 2003
Location: Brentwood, N.Y, USA.
Posts: 16
Thanks: 0
Thanked 0 Times in 0 Posts
Default RAISERROR on my ASP.NET Web Application

     I have a Store Procedure called LogIn. On my ASP.NET web application I'm using the following codes to run this store procedure.

Dim VarifyPassword As String

'Clear the Text in the Label before you get a value.

Me.lblError.Text = ""

MyDataAdapter.SelectCommand = New SqlCommand

MyDataAdapter.SelectCommand.Connection = MyConnection

MyDataAdapter.SelectCommand.CommandType = CommandType.StoredProcedure

MyDataAdapter.SelectCommand.CommandText = "LogIn"

MyDataAdapter.SelectCommand.Parameters.Add(New SqlClient.SqlParameter("@UserID", Me.txtUserID.Text))

MyConnection.Open()

VarifyPassword = MyDataAdapter.SelectCommand.ExecuteScalar()

MyConnection.Close()



Me.lblError.Text = VarifyPassword






My this my Store Procedure.

CREATE Procedure LogIn @UserID VarChar(10)

As

Declare @MyData VarChar(10)


Select @MyData = Status From UserInfo WHERE UserID = @UserID
If @MyData ='1'
Begin
Raiserror (50001,10,1)end
Else
Raiserror (50002,10,1)



Now what I would like to do run this store procedure on my web application and have the RAISERROR display on a Label locate on my web application. Is this possible???



Thanks

Sincerely; Oscar Martinez
__________________
Thanks

Sincerely; Oscar Martinez
 
Old April 16th, 2005, 12:02 AM
Friend of Wrox
Points: 4,332, Level: 27
Points: 4,332, Level: 27 Points: 4,332, Level: 27 Points: 4,332, Level: 27
Activity: 0%
Activity: 0% Activity: 0% Activity: 0%
 
Join Date: Nov 2003
Location: , NJ, USA.
Posts: 1,348
Thanks: 0
Thanked 5 Times in 5 Posts
Default

I believe you need to use a try catch statement:

        Try

        Catch ex As SqlClient.SqlException
           Label.Text = ex.Message
        End Try



 
Old April 17th, 2005, 08:23 PM
Authorized User
 
Join Date: Jun 2003
Location: Brentwood, N.Y, USA.
Posts: 16
Thanks: 0
Thanked 0 Times in 0 Posts
Default


  Thanks for your reply. I have tried your codes and it doesn't return me anything.

    I was reading an article about OutPut parameter. Do you think output parameter is the way to go??

Thanks

Sincerely; Oscar Martinez
 
Old April 17th, 2005, 11:29 PM
Friend of Wrox
Points: 4,332, Level: 27
Points: 4,332, Level: 27 Points: 4,332, Level: 27 Points: 4,332, Level: 27
Activity: 0%
Activity: 0% Activity: 0% Activity: 0%
 
Join Date: Nov 2003
Location: , NJ, USA.
Posts: 1,348
Thanks: 0
Thanked 5 Times in 5 Posts
Default

an OUTPUT parameter will definately work. Just return a string with the error text you want to show in your page.




Similar Threads
Thread Thread Starter Forum Replies Last Post
ASP.NET Web Application Administration dcct84 BOOK: ASP.NET 2.0 Instant Results ISBN: 978-0-471-74951-6 7 September 24th, 2007 04:28 PM
ASP.NET Web Application swifty_programmer ASP.NET 2.0 Professional 14 July 20th, 2007 08:05 AM
performance tuning of asp.net web application swati_joshi ASP.NET 1.0 and 1.1 Basics 3 July 24th, 2006 09:42 AM
can't open asp.net web application project phyzie C# 3 September 26th, 2005 11:40 AM
Convert ASP web application to ASP.NET Steve777 ASP.NET 1.0 and 1.1 Basics 3 June 2nd, 2005 07:26 AM





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