PDA

View Full Version : SQLServerSelectLogin



Tony Dixon
05-07-2004, 07:25 AM
i wish to use SQLServerSelectLogin in my script moved from DEV9 but the call to the SQLServerSelectLogin function returns with a -1

i have followed the notes in the help and added SQLRT.obl to the settings.. i have no SQL scrip in the installer.

has any one go an idea why call in this function return -1 without displaying?

RobCoon
05-07-2004, 11:42 AM
Hello.

There are a couple additional things you will need to do. A lot of the SQL Server support is implemented in a separate DLL, so you will need to have that as part of your setup. Find SQLRT.DLL (it should be in "InstallShield X\Redist\Compressed Files\Language Independent\Intel 32"), and add it in the Setup Files pane, so that it gets installed to SUPPORTDIR.

Then, before you can call any of the other functions, you have to call SQLRTInitialize. SQLRTInitialize takes on parameter that is normally the string to an ini file with the SQL settings that were entered in the IDE. A blank file should suffice to allow you to initialize in order to use the dialogs.

Tony Dixon
05-10-2004, 03:56 AM
Can you provide me with the function definition of SQLRTInitialize, as I can seem to find it in the help or web?

RobCoon
05-10-2004, 11:14 AM
external prototype void SQLRTInitialize( byval string );

This is from Script\SQLRuntime\Include. The only parameter is a string that is supposed to contain the path and filename of the INI file that contains the settings for the SQL Server connections and scripts as set up in the SQL Server view. For your purposes (merely displaying the dialogs), you can just send the path to an empty ini file, just to get the SQL Runtime initialized.

jefftanner
06-15-2004, 07:38 AM
After reading this thread, if I want to use SQLServerSelectLogin() within a InstallScript MSI project (InstallShield X), then I must include SQLRT.DLL and SQLRTInitialize()?

Could you share example scripts using implementing SQLRTInitialize() and utilizing SQLServerSelectLogin()?

I am calling SQLServerSelectLogin() within prototype InstallScript function and it throws an exception, but Err.Description is blank.

However error message box does appear with the message "Internal Error 0x80040707, Description: <blank>"

The values that I passed into SQLServerSelectLogin()

"(local)\\" + szSqlServerName
"sa"
"sapassword"
FALSE



prototype BOOL SQLServerSelectLoginDlg(BYREF STRING, BYREF STRING, BYREF STRING);

///////////////////////////////////////////////////////////////////////////////
//
// Function: SQLServerSelectLoginDlg
//
//
///////////////////////////////////////////////////////////////////////////////
function BOOL SQLServerSelectLoginDlg(szSqlServerNetworkName, szUserId, szPassword)
BOOL bvWindowsLogin;
begin
bvWindowsLogin = FALSE;
try
if ( SQLServerSelectLogin( szSqlServerNetworkName, szUserId, szPassword, bvWindowsLogin ) < ISERR_SUCCESS ) then
return FALSE;
endif;
catch
MessageBox( "SQLServerSelectLogin: " + Err.Description, WARNING);
return FALSE;
endcatch;

return TRUE;
end;


Thanks

Tony Dixon
06-15-2004, 07:46 AM
to get this to work you need to do the following.

1) add the SQLRT.obl in the Build/Settings/Link Options
and add the following text
",<ISProductFolder>\Script\SQLRuntime\Lib\SQLRT.obl"

2) in you script add the following
export prototype SQLServerSelectLogin (STRING,STRING,STRING,INT);
#define _SQLCONV_H_
#include "ISMsiQuery.h"
#include "SQLRT.h"

// for sql page add following line to Build/Settings/Link Options
//,<ISProductFolder>\Script\SQLRuntime\Lib\SQLRT.obl

prototype number OnGetSQLServer(BYREF STRING,BYREF STRING,BYREF STRING,BYREF BOOL);


//---------------------------------------------------------------------------
// OnSQLServerInitialize
//
// The OnSQLServerInitialize event is called by OnFirstUIBefore to
// establish any connections necessary for SQL Server support.
//
// This function will initialize the SQL Server runtime, and attempt to
// make any necessary SQL Server connections, displaying a login dialog
// for each one.
//
// Parameter nBtn indicates whether NEXT or BACK was the result of the
// previously displayed dialog. It is for information purposes only.
//
// Note: This event will not be called automatically in a
// program...endprogram style setup.
//---------------------------------------------------------------------------
function number OnGetSQLServer(szServer,szUser, szPassword,bWinLogin)
number nResult;
number nCount;
string szSettingsFile;
string szConnection;
string szDB;
string szMessage;
string szError[MAX_PATH];
string szKey;
LIST listConnections;
BOOL bNext;
begin

//First initialize SQL Server runtime
szSettingsFile = SUPPORTDIR ^ "SQLRT.ini";
SQLRTInitialize( szSettingsFile );

//Get the names of all the necessary connections
listConnections = SQLRTGetConnections();
ListGetFirstString (listConnections, szConnection);

nCount = 0;

//determine if NEXT or BACK will be returned
//if there are no connections to make

//display login dialog
Dlg_GetSQLServer:
nResult = SQLServerSelectLogin( szServer, szUser, szPassword, bWinLogin );
if( nResult = NEXT ) then

//store data in case we need it again
SQLRTPutConnectionInfo( szConnection, szServer, szUser, szPassword );

//try connection
SdShowMsg(@IDS_MDDBPROCESS +" "+ szServer,TRUE);
if(SQLMDExists(szServer ,szUser ,szPassword)<0) then
MessageBox(@IDS_UNABLETOCONNECTMD,INFORMATION);
nResult=50;
endif;
SdShowMsg("",FALSE);
endif;
if(nResult=50) goto Dlg_GetSQLServer;
return nResult;
end;

then call this function from you code..

hope this is of help

jefftanner
06-15-2004, 09:35 AM
:D Thanks, this is really helpful!

I do have a couple of questions about the code:

1)
You define a prototype function
prototype number OnGetSQLServer(BYREF STRING,BYREF STRING,BYREF STRING,BYREF BOOL);

But the comment for this implemented prototype refers to:
OnSQLServerInitialize(), which is a known event handler.

Is OnGetSQLServer() also a known event handler?

2) If OnGetSQLServer() is not a known event handler, then would would you recommend calling it:
a. within known event handler OnFirstUIBefore()?
or
b. as a custom action, after StartServices?

Tony Dixon
06-15-2004, 09:45 AM
I do have a couple of questions about the code:

1)
You define a prototype function
prototype number OnGetSQLServer(BYREF STRING,BYREF STRING,BYREF STRING,BYREF BOOL);

But the comment for this implemented prototype refers to:
OnSQLServerInitialize(), which is a known event handler.

Is OnGetSQLServer() also a known event handler?

2) If OnGetSQLServer() is not a known event handler, then would would you recommend calling it:
a. within known event handler OnFirstUIBefore()?
or
b. as a custom action, after StartServices?


ok, this is a copy of OnSQLServerInitialize the name was changed as it effected more that i wished it to.

sorry of the mix up i have complete forgot to rename the comment.

you call it in your OnFirstUIBefeore() function like any other dialog.

this sould let you display and use the SQL dialog without having an SQL compoent in the MSI database..

one word of warring the feature is cool but it comes at a price.

the Tech Doc on this dialog says that service pack for NT4 is SP6 or Higher and 2000 is SP3 or higher and XP is SP1 or higher.

this can be a limiting factor in this dialogs usefulness

Hope this helps

let me know how you get on!

Tony Dixon

__________________

jefftanner
06-15-2004, 10:00 AM
Is SQLMDExists() a function you defined?

Tony Dixon
06-15-2004, 10:09 AM
:rolleyes: this is what you get for copy and past.


yes SQLMDExists() is a function i use to check that the detail of the use have ented are correct and that the database is accessable..

jefftanner
06-15-2004, 12:15 PM
How is SQLRT.ini file defined?

In otherwords, what sections and key-value pairs are expected?

It is not defined within the InstallShield on-line documentation.

Do I need to define it, if I already have an MSDE 2000 instance defined (and started) by setup.ini?

jefftanner
06-15-2004, 01:53 PM
Within function OnFirstUIBefore() in Setup.rul, OnGetSQLServer() is called:


Dlg_GetSQLServer:
szSqlServerName = GetProperty("TELESYM_DB_SVC_NAME");
szSqlServerNetworkName = "(local)\\" + szSqlServerName;
szUserId = GetProperty("IS_SQLSERVER_USERNAME");
szPassword = GetProperty("IS_SQLSERVER_PASSWORD");
bWinLogin = FALSE;

nResult = OnGetSQLServer( szSqlServerNetworkName, szUserId, szPassword, bWinLogin );
if (nResult = BACK) goto Dlg_ObjDialogs;


I also added to Support Files view, ISSQLSRV.dll to Language Independent.

However, I get an error message within OnGetSQLServer() at SQLServerSelectLogin().


0x80040702
Failed to load DLL: ISSQLSVR

Tony Dixon
06-16-2004, 02:48 AM
ok in the setting off the build menu.
on the compile/Link tab of that dialog

the librairs(.obl) line is


<ISProductFolder>\Script\ISWi\Lib\iswi.obl,<ISProductFolder>\Script\ISWi\Lib\iswi.obl,<ISProductFolder>\Script\ISRT\Lib\isrt.obl,<ISProductFolder>\Script\ISRT\Lib\isrt.obl,<ISProductFolder>\Script\SQLRuntime\Lib\SQLRT.obl


you will need the SQLrt.dll in the Support File/Language independent

you will find this in the "Installshiel X\redist\compressed files\Language independent\intel 32" directory.

you mite need STDOLE2.tbl and COMCAT.dll from the system dirctory..

hope this is of help..

Tony Dixon
06-16-2004, 02:57 AM
the SQLRT.ini is only used if you supplie a SQL component.
as we are only using the dialog and not the SQL installer, the SQLRT.ini is not required..

but any thing you wish to do with the data you get back form the SQL dialog you have to it you self the installer will not offer any help.

os if you need to create a ODBC connect object, you have to create the code to do it.

that about it. i think...

if you any more question please drop me a line.

Tony Dixon

chrisgwilliams
11-24-2004, 12:53 PM
ok so I have a question about the browse button on the SQLServerSelectLogin dialog.

Does it only display what you provide it in code, or does it actually seek out other SQL Servers the user has access to?

chrisgwilliams
11-24-2004, 01:35 PM
Is SQLRTPutConnectionInfo something you wrote? I can't find any references to it.

C.

baluchen
11-29-2004, 05:43 AM
In order to Browse or select SQL server MDAC to be installed .It is asking to install MDAC. Even after installing still it is thowing an error and exit the installation. Can any one help me on this?


thanks
Baluchen