cancel
Showing results for 
Show  only  | Search instead for 
Did you mean: 
Try the Materials Informatics Toolkit, which is designed to easily handle SMILES data. This and other helpful add-ins are available in the JMP® Marketplace
Choose Language Hide Translation Bar
miguello
Level VI

How to check if "Create Database Connection" is successful?

Many of my scripts connect to a DB as soon as they are started. DB is in intranet, so users need to:

1. Be connected to internal network OR have VPN on

2. Have ODBC source set up correctly

 

Sometimes they don't. 

I want to warn users that the DB is not available instead of script erroring on them. What would be a correct way of checking if "Create Database Connection" was successful and returned a valid handle?

 

Thanks, 

M.

2 REPLIES 2
miguello
Level VI

Re: How to check if "Create Database Connection" is successful?

Is Scriptable(dbc);

works just fine, anybody has a code snippet with modal window that would just close the whole AddIn in case it evaluates "0"?

 

Thanks, 

M.

pmroz
Super User

Re: How to check if "Create Database Connection" is successful?

You could try logic like this:

my_dbc = create database connection("foobar");

if (isempty(my_dbc) | is missing(my_dbc),
	_nw = new window("Create DBC: Empty Value", << modal,
		textbox("Error: The database connection is empty."),
		);
		throw("Empty database connection string");
);