Linker IT Software
Google
Web www.oraxcel.com
menubar-top-links menubar-top-rechts
Home Help Search Login
Welcome, Guest. Please Login.
SQL*XL: Database to Excel bridge litLIB: Excel power functions pack ExcelLock: Locking and securing your valuable Excel spreadsheets encOffice: Protect your Excel file easy and safe encOffice: Protect your Excel file easy and safe
Pages: 1
Own errorhandler for SQL*XL errors (Read 1978 times)
Gerrit-Jan Linker
YaBB Administrator
*****




Posts: 75
Own errorhandler for SQL*XL errors
02.11.10 at 12:30:41
 
Own errorhandler for SQL*XL errors
 
Quote:
Is there a way to handle SQL*XL errors myself? Can SQL*XL errors  be supressed or trapped and handled? I basically never want excel to open a prompt window as it needs to be automated.

 
Yes you can do that.  Add the following two lines after the InitialiseSQLXL statement to raise the errors so you can catch them in your own errorhandler, statement 1, and to suppress the errors from displaying in SQL*XL itself, statement 2:
 
  SQLXL.LITErr.RaiseErrors = True
  SQLXL.LITErr.DisplayAlerts = False
 
Example macro of how your code may look. Note that I have made an error in the connection statement to trigger an error situation:
 

Sub Macro1()
  On Error GoTo ErrorHandler
 
  SQLXL.InitialiseSQLXL
  
  SQLXL.LITErr.RaiseErrors = True
  SQLXL.LITErr.DisplayAlerts = False
  
  SQLXL.Database.ConnectionType = litSQLXLADO
  SQLXL.Database.Connect UserName:="Adminn", PassWord:="", DBAlias:="BIBLIO.MDB (BIBLIO.MDB)", ConnectionString:="Provider=Microsoft.Jet.OLEDB.4.0;Password="""";User ID=Admin;Data Source=BIBLIO.MDB;Mode=Share Deny None;Extended Properties="""";Jet OLEDB:System database="""";Jet OLEDB:Registry Path="""";Jet OLEDB:Database Password="""";Jet OLEDB:Engine Type=4;Jet OLEDB:Database Locking Mode=0;Jet OLEDB:Global Partial Bulk Ops=2;Jet OLEDB:Global Bulk Transactions=1;Jet OLEDB:New Database Password="""";Jet OLEDB:Create System Database=False;Jet OLEDB:Encrypt Database=False;Jet OLEDB:Don't Copy Locale on Compact=False;Jet OLEDB:Compact Without Replica Repair=False;Jet OLEDB:SFP=False", AllowTransactions:=True
 
  Exit Sub
ErrorHandler:
  MsgBox Err.Description, , Err.Number
End Sub
Back to top
 
« Last Edit: 02.11.10 at 12:33:47 by Gerrit-Jan Linker »  

Gerrit-Jan Linker
Linker IT Software
Email WWW Gerrit-Jan Linker   IP Logged
Pages: 1