cancel
Showing results for 
Show  only  | Search instead for 
Did you mean: 
JMP is taking Discovery online, April 16 and 18. Register today and join us for interactive sessions featuring popular presentation topics, networking, and discussions with the experts.
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");
);