DIAdem

cancel
Showing results for 
Search instead for 
Did you mean: 

SQL_Connect error handling

When a SQL_Connect fails because of invalid username or password, I would like to handle that error in my script by checking the SQL_ConnectStat variable and then continue on. However, an ODBC error window pops up and a user has to try and remedy the problem. I want to continue without any user interaction. Including "on error resume next" in the script does nothing to stop the popup message from appearing.

Is it possible to suppress the ODBC error window on a connection failure?





0 Kudos
Message 1 of 7
(5,492 Views)
Hi Cowbreath,
 
Can you post a screen shot of the error message that you are getting?  My first thought is that this message is being thrown by Windows and its ODBC driver.  If this is the case, then there's most likely not anything we can do in DIAdem to suppress the message.  We can look at the Windows settings to see if there is anything on that end that we can do.  A screen shot should show us where the message is being sent from. Thanks and have a good one.
0 Kudos
Message 2 of 7
(5,458 Views)
There are 3 error windows that appear. Image1 and Image2 are obviously Microsoft ODBC error messages. Image3 is a Diadem error whose appearance can be controlled by including the 'On Error Resume Next' statement. My hope in posting this message is that there is an ODBC setting that will affect the behaviour. Another idea is an alternate way to call SQL_Connect or a parameter to pass (maybe in the SQL_CONRESERVE parameter) that would suppress error messages.

As you can see by the error messages, I am using a SQL Server ODBC driver.

I was hoping that someone out there had solved this problem already. Thanks for any help you can give.




Download All
0 Kudos
Message 3 of 7
(5,454 Views)

Hi cowbreath,

Here's a function I have created which seems to return the connectability of a database without those annoying error dialogs.


'MsgBox DBok("Thales_DSN", "sa", "wermut")
MsgBox DBok("Thales_DSN", "sa", "")


'-------------------------------------------------------------------------------------
'******* DBok() ***                                               *** NEW Function ***
'-------------------------------------------------------------------------------------
Function DBok(DSN, User, Password)
DBok = FALSE
  Dim ADO, ADOstr, ErrNum
  IF DSN = "" THEN Exit Function
  ADOstr = "DSN=" & DSN  & ";"
  ADOstr = ADOstr & "UID=" & User & ";"
  ADOstr = ADOstr & "PWD=" & Password
  On Error Resume Next
  Set ADO = CreateObject("ADODB.Connection")
  Call ADO.Open(ADOstr)
  ErrNum = Err.Number
  On Error Goto 0
  IF ErrNum <> 0 THEN Exit Function
DBok = TRUE
End Function ' DBok()


Let me know how it works for you,
Brad Turpin
DIadem Product Support Engineer
National Instruments

Message 4 of 7
(5,424 Views)
Brad,
Thanks for your ADODB example. It worked as I needed. I extended your example to also run an execute to verify the query string since that causes a pop-up error also.

Sorry for the delayed reply. I was assigned to a different project for the last month.

0 Kudos
Message 5 of 7
(5,306 Views)

can you tell me how to put your code in diadem and replace the areas with mySQL connection?

0 Kudos
Message 6 of 7
(4,071 Views)

Hi labsergio,

 

Do you have an ODBC data base driver for your MySQL data base, or is it an OLE data base driver?  Is there any other program that already talks to this data base?  Is there an IT person who can tell you what the "ADO connection string" to this data base is?

 

Brad Turpin

DIAdem Product Support Engineer

National Instruments

 

0 Kudos
Message 7 of 7
(4,024 Views)