Plateforme Level Extreme
Abonnement
Profil corporatif
Produits & Services
Support
Légal
English
.NET web project timeout
Message
Information générale
Forum:
Microsoft SQL Server
Catégorie:
Autre
Divers
Thread ID:
00607381
Message ID:
00608243
Vues:
24
Thanks again, I've been wanting to understand exception objects more, but didn't really have a real motivation before.

One thing good about abstracting the data layer is that my app only has one fill method in it so it was fairly direct to see where to put my try. My only concern is that since this is a generic routine used by every select statement in my app, how do I stop the program from erroneously running further?
Public Overloads Function RunSql(ByVal sSql As String, ByVal sTableName As String) As DataSet
Dim oCmd As SqlCommand = New SqlCommand()
Dim oCn As SqlConnection = Nothing
Dim oDa As SqlDataAdapter = New SqlDataAdapter()
Dim oDs As DataSet = New DataSet()
oCn = Connect()
With oCmd
 .Connection = oCn
 .CommandText = sSql
 .CommandType = CommandType.Text
End With
Try     '//-------------begin trap***********************************
 With oDa
  .SelectCommand = oCmd
  .Fill(oDs, sTableName)
 End With
Catch objException As SqlException
 Dim objError As SqlError
 Dim objLog As EventLog
 If Not EventLog.SourceExists("myApp") Then
  EventLog.CreateEventSource("myApp", "Application")
 End If
 objLog = New EventLog()
 objLog.Source = "myApp"
 For Each objError In objException.Errors
  objLog.WriteEntry(objError.Message, EventLogEntryType.Information)
 Next
End Try '//---------end trap*****************************************
Disconnect(oCn)
Return oDs
End Function
>>The exception has a Message property.
>>I am not seeing any error messages from SQLServer. I don't know how to check this.
>
>What's in the Message property of the SqlException object?
>
>-Mike
Précédent
Suivant
Répondre
Fil
Voir

Click here to load this message in the networking platform