Choose Language Hide Translation Bar
Highlighted
miguello
Level V

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
Highlighted
miguello
Level V

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.

Highlighted
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");
);

Article Labels

    There are no labels assigned to this post.