db.ExecuteSQL Not Working And Not Giving An Exception

Source:

Var db As New ODBCDatabase
db.DataSource = _
  "DRIVER=ODBC Driver 17 for SQL Server;" + _
  "DATABASE=TEST;Trusted_Connection=Yes;SERVER=localhost"
db.Connect
try
  db.ExecuteSQL("selecf 1")
catch e As RuntimeException // e vanished from the debug window
  Var ex As Variant = e     // so does ex
  Var isDbEx As Boolean = e Isa DatabaseException
  break
End
break

By using DRIVER={SQL Server}; instead of DRIVER=ODBC Driver 17 for SQL Server;, i can connect and see the exception as expected:

Nope. You are outside the catch and inspecting db.

You should see “e” and “ex” inside the catch. And both vanished in my Xojo 2025r2.65483

How are they in your debugger as show above?

Sry, my fault :slight_smile:

Let it break by itself as written in the code, don’t break it in advance by hand. isDbEx should be true.

Also, what version and build of your Xojo? It is showing “e” as it should.

Busy now. :wink:

I don’t know if this is the solution to your problem, but I invite you to place this instruction:
#Pragma BreakOnExceptions

Your code would be:

#Pragma BreakOnExceptions on
Try
  //execute update
  db.ExecuteSQL(sql,LogID)
  Return True
  
Catch e As DatabaseException
  ShowError e.Message, CurrentMethodName
  Return False
end Try
#Pragma BreakOnExceptions off

I guess that that is not his problem.