Quantcast
Channel: Visual COBOL - Forum - Recent Threads
Viewing all articles
Browse latest Browse all 4356

RE: Cobol .Net Exception Handling

$
0
0

I don't have MySQL readily available but I tested this same thing with the SQL Server SqlClient provider and the exception handling works for me. If I pass an invalid connection string it jumps to the catch if it is ok it just continues.

This is what I tried:

           declare str as string
           declare connectionString as string = "Data Source=local;Initial Catalog=Northwind;"
                & "Integrated Security=true;"
           try
              perform using connection as type SqlConnection = new SqlConnection
                 set connection::ConnectionString = connectionString
                 invoke connection::Open
                 display "no exception"
           end-perform
           Catch myex as type SqlException
              set str to "Source " & myex::Source
              set str = str & "Number " & myex::StackTrace
              set str = str & "Line Number " & myex::TargetSite
              set str = str & "Data Exception " & myex::GetType::ToString
              invoke type System.Diagnostics.Debug::WriteLine(str)
           end-try
           
           display "after try"
           goback.

Viewing all articles
Browse latest Browse all 4356

Trending Articles



<script src="https://jsc.adskeeper.com/r/s/rssing.com.1596347.js" async> </script>