RaiseError

S

shapper

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_CreateBlog")
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
 
O

OZI

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
 
D

Darren Kopp

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_CreateBlog")
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/library/system.data.sqlclient.sqlexception.errors.aspx
SqlError MSDN - http://msdn2.microsoft.com/en-us/library/system.data.sqlclient.sqlerror.aspx
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Members online

No members online now.

Forum statistics

Threads
473,755
Messages
2,569,537
Members
45,021
Latest member
AkilahJaim

Latest Threads

Top