PDA

View Full Version : Database name for SQL Server Connection



jdukes
07-21-2005, 01:39 PM
I need to give users the ability to provide the database name for an SQL Connection at run-time. I am unable to specify a Catalog Name in the SQL Connect-General tab because database names for the product in question may vary.

Previously, I've used a database update utility to handle all script execution. This homespun utility allows the user to select a DSN and provide a userid and password for connection login. I was hoping to recreate like functionality from within InstallShield 11, but have been unable to find a way to update the catalog name at run-time.

SQLRTGetConnectionInfo will return the database name, but SQLRTPutConnectionInfo does not have a database parameter for updating that value.

Am I missing something simple here?

Thanks

DMorisseau
07-29-2005, 02:42 PM
I had a somewhat similar situation in that the database name could vary from customer to customer (though my project was a Basic MSI project) What I had to do was create a dialog and write some InstallScript code to populate the drop-down list with the names of qualifying databases. I created a custom action to fire on the Next button of the SQL Login screen which called the code. I then set the value of IS_SQLSERVER_DATABASE to be the selected database.

hidenori
08-01-2005, 12:09 PM
In an InstallScript project, you can call SQLRTConnectDB( szConnection, szDB, szServer, bTrust, szUserName, szPassword ) function instead of SQLRTConnect() in order to connect to a specific database.

Thiyagu
08-09-2005, 06:53 AM
Hi,
SQLRTConnectDB() is not working with Installshield 11.0. I could see only SQLRTConnect2() method for establising the connection. Is there any other method similar to SQLRTConnectDB()?

Thanks,
Thiyagu

hidenori
08-09-2005, 10:31 AM
Thiyagu,

Do you see any error? or the desired database not created with no error?

Thiyagu
08-10-2005, 04:29 AM
Hi Hidenori,
I'm getting the following error,
Error number: 0x80040707
Description: DLL function call crashed:SQLRT.ISSQLServerConnectDB


I have done the following

1, In Installscript project, created a SQLConnection with blank catalog name.
2, In Install script OnSQLServerInitialize function commented
//nResult = SQLRTConnect2( szConnection, szServer, bWinLogin, szUser, szPassword, szDatabaseServer );
and added
szDB1 = "TestDB";
nResult = SQLRTConnectDB( szConnection, szDB1, szServer, bWinLogin, szUser, szPassword );


Thanks for your help

Thiyagu

jdukes
08-10-2005, 10:23 AM
Using this same approach, I get no error message. However, the installer simply locks-up and never processes anything beyond SQLRTConnectDB. Even when debugging, the entire script is successfully run up to the call of this function. Then nothing happens... no timeout, no error message, nothing. At that point, neither the debugger nor the installer UI responds to user input and the processes have to be killed in task manager.

hidenori
08-11-2005, 04:20 PM
I have attached the custom fix for the SQLRTConnectDB() problem to this post. To apply this fix, replace the \Program Files\InstallShield 11\Compressed Files\Language Independent\Intel 32\SQLRT.dll with the new one, then rebuild your setup. Note that it requires InstallShield 11.0 installed on the system. If you still experience the error, please let me know.

Rakesh Gupta
06-05-2006, 11:22 PM
Hi JDukes

Did you get your problem related to SQL solved in InstallScript project. I'm also having similar problem where I need to populate a dialog box with available connection on the basis of server selected by user.

Then ask the user to select the database. Connect to Database and save same info into a file.

But I'm stuck here as InstallScript does not provide any functionality to display available databases on the basis of selected Server.

Can you help me out.

Regards

Rakesh

DMorisseau
06-08-2006, 08:52 AM
Here's a function I use to list out the databases installed on my server.
You'll presumably have already captured g_szServerName, g_szUserName, g_szAuth, g_szPassword from the SQLLogin dialog

I had previously declared listOldDBNames to store the list of databases that I later display in a custom dialog box.

You'll want to substitute "ConfigDB" with a tablename that is unique to your application's DB.

function LookForExistingDBs()
OBJECT oDatabase,oSQLServer,oTbl;
STRING szoDatabase, szSQLServer,szDatabaseName;
STRING szQuery, szOrder, szDBQuery,szDBDesc,szErr;
NUMBER nCount, nvBuffSize, order;
NUMBER hView, hDatabase,nResult, hView2;
BOOL bDone;
HWND hRec;
begin
Enable(HOURGLASS);

// Instantiate a DMO object to get the list of HPXL Databases

szSQLServer = "SQLDMO.SQLServer";
set oSQLServer = CreateObject(szSQLServer);

oSQLServer.LoginTimeout = 15;

oSQLServer.LoginSecure = (g_szAuth = "0");
oSQLServer.Connect(g_szServerName,g_szUserName,g_szPassword);


szoDatabase = "SQLDMO.Database";
set oDatabase = CreateObject(szoDatabase);

for nCount = 1 to oSQLServer.Databases.Count
set oDatabase = oSQLServer.Databases(nCount);

try
set oTbl = oDatabase.Tables("ConfigDB");
order = order + 1;
szDatabaseName = oDatabase.Name;
nResult = ListAddString(listOldDBNames,szDatabaseName,AFTER);

catch
nResult = Err.Number;
szErr = Err.Description;
endcatch;
endfor;

// Clean up the objects that were used

set oDatabase = NOTHING;
oSQLServer.Disconnect;
set oSQLServer = NOTHING;
Disable(HOURGLASS);
return 0;

end;

Rakesh Gupta
06-08-2006, 10:04 AM
Dear Morriseau

Thanks for the function script to build a list of Databases.

Another point, after building list of available databases, how to display so that user can select one of the available databases.

Regards

Rakesh