Velocity Reviews - Computer Hardware Reviews

Velocity Reviews > Newsgroups > Programming > ASP .Net > RaiseError

Reply
Thread Tools

RaiseError

 
 
shapper
Guest
Posts: n/a
 
      09-14-2007
Hello,

I am raising an error on my SQL 2005 procedure as follows:

RAISERROR(@ErrorMessage, @ErrorSeverity, 1)

How can I access it in my ASP.NET code? I am using Enterprise Library
Data Block to access the database.

This is the code I have:

Try
Dim dbBlog As Database = DatabaseFactory.CreateDatabase("MyDB")
Dim dbcBlog As DbCommand =
dbBlog.GetStoredProcCommand("by27_Blogger_CreateBl og")
dbBlog.AddInParameter(dbcBlog, "@BlogName", DbType.String, name)
dbBlog.AddInParameter(dbcBlog, "@BlogComment", DbType.String,
comment)
dbBlog.ExecuteNonQuery(dbcBlog)
Catch ex As System.Exception
End Try

Thanks,

Miguel

 
Reply With Quote
 
 
 
 
OZI
Guest
Posts: n/a
 
      09-14-2007
Did you put a break point at your Catch statement?
If not caching the error then maybe the DataBock might be eating it or
something.
is Severity Level 1 enough? why not increase it to 16 or beyond.

OZI


"shapper" <(E-Mail Removed)> wrote in message
news:(E-Mail Removed) ups.com...
> Hello,
>
> I am raising an error on my SQL 2005 procedure as follows:
>
> RAISERROR(@ErrorMessage, @ErrorSeverity, 1)
>
> How can I access it in my ASP.NET code? I am using Enterprise Library
> Data Block to access the database.
>
> This is the code I have:
>
> Try
> Dim dbBlog As Database = DatabaseFactory.CreateDatabase("MyDB")
> Dim dbcBlog As DbCommand =
> dbBlog.GetStoredProcCommand("by27_Blogger_CreateBl og")
> dbBlog.AddInParameter(dbcBlog, "@BlogName", DbType.String, name)
> dbBlog.AddInParameter(dbcBlog, "@BlogComment", DbType.String,
> comment)
> dbBlog.ExecuteNonQuery(dbcBlog)
> Catch ex As System.Exception
> End Try
>
> Thanks,
>
> Miguel
>



 
Reply With Quote
 
 
 
 
Darren Kopp
Guest
Posts: n/a
 
      09-14-2007
On Sep 14, 1:02 pm, shapper <(E-Mail Removed)> wrote:
> Hello,
>
> I am raising an error on my SQL 2005 procedure as follows:
>
> RAISERROR(@ErrorMessage, @ErrorSeverity, 1)
>
> How can I access it in my ASP.NET code? I am using Enterprise Library
> Data Block to access the database.
>
> This is the code I have:
>
> Try
> Dim dbBlog As Database = DatabaseFactory.CreateDatabase("MyDB")
> Dim dbcBlog As DbCommand =
> dbBlog.GetStoredProcCommand("by27_Blogger_CreateBl og")
> dbBlog.AddInParameter(dbcBlog, "@BlogName", DbType.String, name)
> dbBlog.AddInParameter(dbcBlog, "@BlogComment", DbType.String,
> comment)
> dbBlog.ExecuteNonQuery(dbcBlog)
> Catch ex As System.Exception
> End Try
>
> Thanks,
>
> Miguel


Catch SqlException. You can find out what the raiseerror was with the
Errors collection. You can use this as a reference

SqlException MSDN - http://msdn2.microsoft.com/en-us/lib...on.errors.aspx
SqlError MSDN - http://msdn2.microsoft.com/en-us/lib....sqlerror.aspx

 
Reply With Quote
 
 
 
Reply

Thread Tools

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 On
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are Off




Advertisments