I cannot seem to trap an exception using Microsoft.ApplicationBlocks.Data. I purposely entered a bogus query, yet no error is returned.
However, when I change the database login credentials to something invalid, I get an error. Any ideas why I can't trap an error with an invalid query? Here is the code:
rokal
Member
5 Points
1 Post
Can't trap SqlExeption using Microsoft.ApplicationBlocks.Data
May 12, 2005 08:01 PM|LINK
I cannot seem to trap an exception using Microsoft.ApplicationBlocks.Data. I purposely entered a bogus query, yet no error is returned.
However, when I change the database login credentials to something invalid, I get an error. Any ideas why I can't trap an error with an invalid query? Here is the code:
Imports System.Data
Imports
System.Data.SqlClientImports
Microsoft.ApplicationBlocks.DataDim DBConnectString As String
Dim rdr As SqlClient.SqlDataReaderDBConnectString = ConfigurationSettings.AppSettings.Item("DbConnectString")
Tryrdr = SqlHelper.ExecuteReader(DBConnectString, CommandType.Text, "select * from bogustablename")
DataGrid1.DataSource = rdr
DataGrid1.DataBind()
Catch sqlEx As SqlClient.SqlException If Not rdr Is Nothing Thenrdr.Close()
End IfResponse.Write(sqlEx.ToString)
Catch ex As Exception If Not rdr Is Nothing Thenrdr.Close()
End IfResponse.Write(ex.ToString)
Finally End Try