kaushick
Posts: 3
Joined: Thu Oct 14, 2004 12:47 am

Creating a DSN

Gday all,

We just purchased the prof verion of Advanced Installer at our company. I need to create a install file for our software and part of the project is to be able to create a DSN to a database in SQL server.
I want to be able to prompt the user to select the server where the database resides and after the selection is made the DSN should be created with the specified username and the password. I read up on how the attributes work and all but I cant seem to figure out how I can create a custom action so the user is asked to select the server.
Please let me know how to create a dsn. Cheers.

-Kaushick
Philip
Posts: 27
Joined: Fri Apr 04, 2003 2:06 pm
Contact: Website

Hi Kaushick,

The custom action that you need to create will ask the user for the required information and then create a DSN based on this information.

We will add this functionality within the Advanced Installer in a future version. Meanwhile, here's what you need to do to get things going:

1) Create a .dll with a function that will display a dialog asking for the server name, user name and password.
2) Use the SQLConfigDataSource() function to configure the data source programatically. Example:

RETCODE retcode;
UCHAR *szDriver = "SQL Server";
UCHAR *szAttributes =
"DSN=my65dsn\0DESCRIPTION=SQLConfigDSN Sample\0"
"SERVER=my65server\0ADDRESS=HRServer\0NETWORK=dbmssocn\0"
"DATABASE=pubs\0";

retcode = SQLConfigDataSource(NULL, ODBC_ADD_DSN, szDriver, szAttributes);

Alternatively, you can set the first parameter as a valid window handle, and the dialog box from ODBC Administrator used to setup an ODBC Sql DataSource will be displayed.

BOOL res = SQLConfigDataSource(m_hWnd, ODBC_ADD_SYS_DSN,
"SQL Server", "DSN=MySQL DataSource");

Hope this helps,

Philip
Philip Petrescu - Advanced Installer Team
Follow us: Twitter - Facebook - YouTube
kaushick
Posts: 3
Joined: Thu Oct 14, 2004 12:47 am

Thanks a lot for that!

Return to “Common Problems”