![]() | |
![]() |
| | Thread Tools | Search this Thread | Display Modes |
#1
| |||
| |||
|
#2
| |||
| |||
|
|
Hi, Using VS2005, SQL Server 2005. The SqlError.Class property always seems to be 0 when retrieving informational messages via the SqlConnection.InfoMessage event. Sample code to reproduce : == private void button1_Click(object sender, EventArgs e) { string yourConnString = // your connection string here using (SqlConnection conn = new SqlConnection(yourConnString)) { conn.Open(); conn.InfoMessage += new SqlInfoMessageEventHandler(OnInfoMessage); string sql = "raiserror('done', 10, 127)"; SqlCommand cmd = new SqlCommand(sql, conn); cmd.ExecuteNonQuery(); } } protected void OnInfoMessage( object sender, SqlInfoMessageEventArgs args) { foreach (SqlError err in args.Errors) { MessageBox.Show("Class " + err.Class + ", State " + err.State); } } == The message box displays : "Class 0, State 127". I'm expecting to get 10 as the value of Class. Can anyone shed any ideas into this ? TIA, Stephen |
![]() |
| Thread Tools | Search this Thread |
| Display Modes | |
| |