Google Groups no longer supports new Usenet posts or subscriptions. Historical content remains viewable.
Dismiss

How can I do ODBC setting?

2 views
Skip to first unread message

Linh Nguyen

unread,
May 24, 2000, 3:00:00 AM5/24/00
to cho minsu
This involve adding/changing info to registry..
Actually, registry is enough to create the SYSTEM DSN

LCN

cho minsu wrote:

> I am using InstallShield for Microsoft Visual C++6.
>
> But I can't apply ODBC setting.
>
> I want to add data source in SYSTEM DSN Setting.
>
> I read Document ID: Q102888 but I can't easily understand.
>
> odbccp32.dll is not referenced easily.
>
> Please tell me how....with example.
>
> I want to know how to do.
>
> Thanks.
>
> ////////////////////////////////////////////////////////////////////////////////
> //
> // IIIIIII SSSSSS
> // II SS InstallShield (R)
> // II SSSSSS (c) 1996-1997, InstallShield Software Corporation
> // II SS (c) 1990-1996, InstallShield Corporation
> // IIIIIII SSSSSS All Rights Reserved.
> //
> //
> // File Name: Setup.rul
> //
> // Description: InstallShield script
> //
> // Comments: This is the script for KB "HOWTO: Installing Data Sources
> // Without Using the ODBC Template".
> // This script gets the names of all the files in the installation,
> // and installs DSNs by calling Windows APIs directly.
> //
> ////////////////////////////////////////////////////////////////////////////////
>
> prototype ODBCCP32.SQLConfigDataSource ( HWND, SHORT, STRING, STRING );
> prototype ODBCCP32.SQLInstallerError ( SHORT, BYREF LONG, BYREF STRING, SHORT, BYREF SHORT);
> prototype ISODBCDisplaySQLInstallerErrorMsg ( STRING );
>
> #define SQL_MAX_MESSAGE_LENGTH 512
> #define SQL_SUCCESS_WITH_INFO 1
> #define SQL_NO_DATA 100
> #define SQL_ERROR -1
>
> HWND hwnd;
> NUMBER nRes,nError,nvLen,nCount;
> STRING szArgs,szDBQ;
>
> program
>
> UseDLL(WINSYSDIR ^ "odbccp32.dll");
>
> szDBQ = PROGRAMFILES ^ "Microsoft Office\\Office\\Samples\\Solutions.mdb";
>
> szArgs = "DSN=notemplate|"+
> "Description=My Description|"+
> "DBQ=" + szDBQ + "|" +
> "Driver=" + WINSYSDIR ^ "odbcjt32.dll|" +
> "FIL=MS Access|" +
> "UID=|";
> // Replace all semicolons with NULL characters to create null-delimited,
> // double-NULL terminated string, which is the format needed to pass to SQL functions.
> szArgs = szArgs + '|;';
> nvLen = StrLength ( szArgs );
> nvLen = nvLen - 1;
> nCount = 0;
> for nCount = 0 to nvLen
> if ( szArgs[nCount] = '|' ) then
> szArgs[nCount] = '\0';
> endif;
> endfor;
>
>
> //hwnd = GetWindowHandle ( HWND_INSTALL );
> nRes = SQLConfigDataSource(hwnd ,1,"Microsoft Access Driver (*.mdb)",szArgs);
>
> if (nRes = FALSE) then
> nError = ISODBCDisplaySQLInstallerErrorMsg ( "whocares" );
> endif;
>
> UnUseDLL(WINSYSDIR ^ "odbccp32.dll");
>
> endprogram
>
> function ISODBCDisplaySQLInstallerErrorMsg ( szODBCComponent )
> LONG fErrorCode;
> NUMBER nvResult;
> STRING szErrorMsg[SQL_MAX_MESSAGE_LENGTH];
> SHORT cbErrorMsg, cbErrorMsgMax, iError;
> POINTER pfErrorCode, pcbErrorMsg;
> begin
>
> pfErrorCode = &fErrorCode;
> pcbErrorMsg = &cbErrorMsg;
> iError = 1;
> cbErrorMsgMax = SQL_MAX_MESSAGE_LENGTH;
> nvResult = SQLInstallerError ( iError, fErrorCode, szErrorMsg,
> cbErrorMsgMax, pcbErrorMsg );
> if ( TRUE ) then
> if ( nvResult = SQL_NO_DATA || nvResult = SQL_ERROR ) then
> MessageBox ( @ISODBC_ERR_NOERRDATA + "\n" + szODBCComponent, SEVERE );
> elseif ( nvResult = SQL_SUCCESS_WITH_INFO ) then
> SprintfBox ( SEVERE, "", @ISODBC_ERR_ERRBUFFSHORT + "\n" +
> @ISODBC_ERR_NUMBER + "\n" + szODBCComponent, fErrorCode );
> else
> MessageBox ( szErrorMsg + "\n" + szODBCComponent, SEVERE );
> endif;
> endif;
>
> return ( fErrorCode );
>
> end;


0 new messages