Wrox Programmer Forums

Need to download code?

View our list of code downloads.

Go Back   Wrox Programmer Forums > SQL Server > SQL Server 2000 > SQL Server 2000
Password Reminder
Register
| FAQ | Members List | 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 tens of thousands of software programmers and website developers including Wrox book authors and readers. As a guest, you can read any forum posting. By joining today you can post your own programming questions, respond to other developers’ questions, and eliminate the ads that are displayed to guests. Registration is fast, simple and absolutely free .
DRM-free e-books 300x50
Reply
 
Thread Tools Search this Thread Display Modes
  #1 (permalink)  
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
Reply With Quote
  #2 (permalink)  
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



Reply With Quote
  #3 (permalink)  
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
Reply With Quote
  #4 (permalink)  
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.
Reply With Quote
Reply


Thread Tools Search this Thread
Search this Thread:

Advanced Search
Display Modes

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is Off
HTML code is Off
Trackbacks are Off
Pingbacks are On
Refbacks are Off


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



All times are GMT -4. The time now is 06:28 AM.


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