#ifndef SQLCONNECTPARAM__RUL
#define SQLCONNECTPARAM__RUL
#include "Func.rul"
#define RES_PBUT_NEXT 1 // ID of 'Next' push button
#define RES_PBUT_CANCEL 9 // ID of 'Cancel' push button
#define RES_PBUT_BACK 12
#define RES_DIALOG_NAME "SQLConnectParam"
#define RES_DIALOG_EdtServer 1400
#define RES_DIALOG_EdtDatabase 1401
#define RES_DIALOG_EdtUser 1402
#define RES_DIALOG_EdtPassword 1403
#define RES_DIALOG_EdtPassword2 1403
export prototype SQLConnectParam(byref string /*Server Name*/,byref string/*Database*/,byref string/*User Name*/,byref string/*Password*/);
export prototype SQLConnectParam_TestParam(string,string,string,string);
function SQLConnectParam_TestParam(szServer,szDatabase,szUser,szPassword)
variant Conn,RS;
string szConnectString;
BOOL bResult;
string SQL;
begin
bResult = FALSE;
MessageBox(@MSGODBCSet,INFORMATION);
SdShowMsg(@IDS__SQLConnect_Test,TRUE);
szConnectString = "Driver={SQL Server};Server=%s;database=%s;UID=%s;PWD=%s";
trs_sql(szServer);trs_sql(szDatabase);trs_sql(szUser);trs_sql(szPassword);
Sprintf(szConnectString,szConnectString,szServer,szDatabase,szUser,szPassword);
set Conn = CreateObject("ADODB.Connection");
try
Conn.Open(szConnectString);
if (IsObject(Conn)) then
bResult = TRUE;
endif;
catch
bResult = FALSE;
endcatch;
if(!bResult)then
SdShowMsg(@IDS__SQLConnect_Test,FALSE);
MessageBox(@IDS__SQLConnect_ConnectError,SEVERE);
endif;
set Conn = NOTHING;
SdShowMsg(@IDS__SQLConnect_Test,FALSE);
return bResult;
end;
function SQLConnectParam(szServer,szDatabase,szUser,szPassword)
STRING szDialogName, szDLLName, szDialog;
NUMBER nDialog, nResult, nCmdValue;
BOOL bDone;
HWND hInstance, hwndParent;
LIST lWebServer;
STRING szMessage;
string szTmp;
string szS,szU,szD,szU2;
begin
szDialogName = RES_DIALOG_NAME;
hInstance = 0;
szDLLName = ISUSER;
//szDialog = "";
hwndParent = 0;
nResult = DefineDialog (szDialogName, hInstance, szDLLName,
hInstance, RES_DIALOG_NAME, hwndParent,
HWND_INSTALL, DLG_MSG_STANDARD|DLG_CENTERED);
// Check for an error.
if (nResult < 0) then
MessageBox ("An error occurred while defining the dialog.", SEVERE);
bDone = TRUE;
abort;
endif;
// Initialize the indicator used to control the while loop.
bDone = FALSE;
repeat
nCmdValue = WaitOnDialog(szDialogName);
switch (nCmdValue)
case DLG_CLOSE:
// The user clicked the window's close button.
Do (EXIT);
case DLG_ERR:
MessageBox ("Unable to display dialog. Setup canceled.", SEVERE);
abort;
case DLG_INIT:
CtrlSetText(szDialogName,RES_DIALOG_EdtServer,szServer);
CtrlSetText(szDialogName,RES_DIALOG_EdtDatabase,szDatabase);
CtrlSetText(szDialogName,RES_DIALOG_EdtUser,szUser);
CtrlSetText(szDialogName,RES_DIALOG_EdtPassword,szPassword);
CtrlSetText(szDialogName,RES_DIALOG_EdtPassword2,szPassword);
case RES_PBUT_CANCEL:
Do (EXIT);
case RES_PBUT_BACK:
bDone = TRUE;
nResult = 12;
case RES_PBUT_NEXT:
CtrlGetText(szDialogName,RES_DIALOG_EdtServer,szServer);
CtrlGetText(szDialogName,RES_DIALOG_EdtDatabase,szDatabase);
CtrlGetText(szDialogName,RES_DIALOG_EdtUser,szUser);
CtrlGetText(szDialogName,RES_DIALOG_EdtPassword,szPassword);
CtrlGetText(szDialogName,RES_DIALOG_EdtPassword2,szTmp);
if(szTmp==szPassword)then
bDone = SQLConnectParam_TestParam(szServer,szDatabase,szUser,szPassword);
else
MessageBox(@IDS__SQLConnect_ConfirPassword,SEVERE);
endif;
nResult = 1;
endswitch;
CtrlGetText(szDialogName,RES_DIALOG_EdtServer,szS);
CtrlGetText(szDialogName,RES_DIALOG_EdtDatabase,szD);
CtrlGetText(szDialogName,RES_DIALOG_EdtUser,szU);
EnableControl(szDialogName,RES_PBUT_NEXT,szS!="" && szU!="" && szD!="" );
until bDone;
EndDialog (szDialogName);
ReleaseDialog (szDialogName);
return nResult;
end;
#endif
#define SQLCONNECTPARAM__RUL
#include "Func.rul"
#define RES_PBUT_NEXT 1 // ID of 'Next' push button
#define RES_PBUT_CANCEL 9 // ID of 'Cancel' push button
#define RES_PBUT_BACK 12
#define RES_DIALOG_NAME "SQLConnectParam"
#define RES_DIALOG_EdtServer 1400
#define RES_DIALOG_EdtDatabase 1401
#define RES_DIALOG_EdtUser 1402
#define RES_DIALOG_EdtPassword 1403
#define RES_DIALOG_EdtPassword2 1403
export prototype SQLConnectParam(byref string /*Server Name*/,byref string/*Database*/,byref string/*User Name*/,byref string/*Password*/);
export prototype SQLConnectParam_TestParam(string,string,string,string);
function SQLConnectParam_TestParam(szServer,szDatabase,szUser,szPassword)
variant Conn,RS;
string szConnectString;
BOOL bResult;
string SQL;
begin
bResult = FALSE;
MessageBox(@MSGODBCSet,INFORMATION);
SdShowMsg(@IDS__SQLConnect_Test,TRUE);
szConnectString = "Driver={SQL Server};Server=%s;database=%s;UID=%s;PWD=%s";
trs_sql(szServer);trs_sql(szDatabase);trs_sql(szUser);trs_sql(szPassword);
Sprintf(szConnectString,szConnectString,szServer,szDatabase,szUser,szPassword);
set Conn = CreateObject("ADODB.Connection");
try
Conn.Open(szConnectString);
if (IsObject(Conn)) then
bResult = TRUE;
endif;
catch
bResult = FALSE;
endcatch;
if(!bResult)then
SdShowMsg(@IDS__SQLConnect_Test,FALSE);
MessageBox(@IDS__SQLConnect_ConnectError,SEVERE);
endif;
set Conn = NOTHING;
SdShowMsg(@IDS__SQLConnect_Test,FALSE);
return bResult;
end;
function SQLConnectParam(szServer,szDatabase,szUser,szPassword)
STRING szDialogName, szDLLName, szDialog;
NUMBER nDialog, nResult, nCmdValue;
BOOL bDone;
HWND hInstance, hwndParent;
LIST lWebServer;
STRING szMessage;
string szTmp;
string szS,szU,szD,szU2;
begin
szDialogName = RES_DIALOG_NAME;
hInstance = 0;
szDLLName = ISUSER;
//szDialog = "";
hwndParent = 0;
nResult = DefineDialog (szDialogName, hInstance, szDLLName,
hInstance, RES_DIALOG_NAME, hwndParent,
HWND_INSTALL, DLG_MSG_STANDARD|DLG_CENTERED);
// Check for an error.
if (nResult < 0) then
MessageBox ("An error occurred while defining the dialog.", SEVERE);
bDone = TRUE;
abort;
endif;
// Initialize the indicator used to control the while loop.
bDone = FALSE;
repeat
nCmdValue = WaitOnDialog(szDialogName);
switch (nCmdValue)
case DLG_CLOSE:
// The user clicked the window's close button.
Do (EXIT);
case DLG_ERR:
MessageBox ("Unable to display dialog. Setup canceled.", SEVERE);
abort;
case DLG_INIT:
CtrlSetText(szDialogName,RES_DIALOG_EdtServer,szServer);
CtrlSetText(szDialogName,RES_DIALOG_EdtDatabase,szDatabase);
CtrlSetText(szDialogName,RES_DIALOG_EdtUser,szUser);
CtrlSetText(szDialogName,RES_DIALOG_EdtPassword,szPassword);
CtrlSetText(szDialogName,RES_DIALOG_EdtPassword2,szPassword);
case RES_PBUT_CANCEL:
Do (EXIT);
case RES_PBUT_BACK:
bDone = TRUE;
nResult = 12;
case RES_PBUT_NEXT:
CtrlGetText(szDialogName,RES_DIALOG_EdtServer,szServer);
CtrlGetText(szDialogName,RES_DIALOG_EdtDatabase,szDatabase);
CtrlGetText(szDialogName,RES_DIALOG_EdtUser,szUser);
CtrlGetText(szDialogName,RES_DIALOG_EdtPassword,szPassword);
CtrlGetText(szDialogName,RES_DIALOG_EdtPassword2,szTmp);
if(szTmp==szPassword)then
bDone = SQLConnectParam_TestParam(szServer,szDatabase,szUser,szPassword);
else
MessageBox(@IDS__SQLConnect_ConfirPassword,SEVERE);
endif;
nResult = 1;
endswitch;
CtrlGetText(szDialogName,RES_DIALOG_EdtServer,szS);
CtrlGetText(szDialogName,RES_DIALOG_EdtDatabase,szD);
CtrlGetText(szDialogName,RES_DIALOG_EdtUser,szU);
EnableControl(szDialogName,RES_PBUT_NEXT,szS!="" && szU!="" && szD!="" );
until bDone;
EndDialog (szDialogName);
ReleaseDialog (szDialogName);
return nResult;
end;
#endif