I wish to add a DSN to my 32-bit ODBC List Programmatically 
Author Message
 I wish to add a DSN to my 32-bit ODBC List Programmatically


I wish to add a DSN to my 32-bit ODBC list programmatically but cannot find
any examples on how to do so.  I Would prefer a C or C++ solution.

Thanks



Mon, 20 Nov 2000 03:00:00 GMT  
 I wish to add a DSN to my 32-bit ODBC List Programmatically

Hi

 There is a  API function  "ConfigDSN" for setting up 32bit ODBC.

 You'll find some information in ODBC SDK Programars' reference...

 Hope this help

--- Caco

Jeff Palmer wrote in article

Quote:

> I wish to add a DSN to my 32-bit ODBC list programmatically but cannot
find
> any examples on how to do so.  I Would prefer a C or C++ solution.

> Thanks



Tue, 21 Nov 2000 03:00:00 GMT  
 I wish to add a DSN to my 32-bit ODBC List Programmatically

Hi Jeff,

You could look at the SQLConfigDataSource ODBC API. This creates a DSN
programmatically. There is an article which describes how to do the same.
The article is "Data Source: Programmatically Configuring an ODBC Data
Source".

Hope this helps.

Regards,
Madhav.

Quote:


>I wish to add a DSN to my 32-bit ODBC list programmatically but cannot find
>any examples on how to do so.  I Would prefer a C or C++ solution.

>Thanks



Sat, 25 Nov 2000 03:00:00 GMT  
 I wish to add a DSN to my 32-bit ODBC List Programmatically

Hi Jeff,

You could look at the SQLConfigDataSource API. Using this you could create
DSN programmatically. You could also look at the article "Data Source:
Programmatically Configuring an ODBC Data Source" which describes the same.

Hope this helps,

Regards,
Madhav.

Quote:


>I wish to add a DSN to my 32-bit ODBC list programmatically but cannot find
>any examples on how to do so.  I Would prefer a C or C++ solution.

>Thanks



Sat, 25 Nov 2000 03:00:00 GMT  
 I wish to add a DSN to my 32-bit ODBC List Programmatically

Hi Jeff,

You could look at the SQLConfigDataSource ODBC API. This creates a DSN
programmatically. There is an article which describes how to do the same.
The article is "Data Source: Programmatically Configuring an ODBC Data
Source".

Hope this helps.

Regards,
Madhav.

Quote:


>I wish to add a DSN to my 32-bit ODBC list programmatically but cannot find
>any examples on how to do so.  I Would prefer a C or C++ solution.

>Thanks



Sat, 25 Nov 2000 03:00:00 GMT  
 I wish to add a DSN to my 32-bit ODBC List Programmatically

Dear Jeff:
  It's lucky day for you. I had source code follow below....

 // Add the datasource to ODBC for the user:
        sprintf(szAttributes,
                   "DSN=DSNNamer|"
                   "Description=Description of DSN|"
       "DRIVERID=25|"
       "FIL=MS Access|"
       "DEFAULTDIR=%s|"
       "MaxBufferSize=1024|"
       "MaxScanRows=16|"
       "PageTimeOut=10|"
                   "DBQ=%s|", buffer,  m_DSN);
        int nLength = (int)strlen(szAttributes);
        for (int i = 0; i < nLength; i++)
        {
                if (szAttributes[i] == '|')
                {
                        szAttributes[i] = '\0';
                }
        }

    rRet = SQLConfigDataSource(
   NULL,
   ODBC_ADD_DSN,
   "Microsoft Access Driver (*.mdb)",
            szAttributes);



Quote:

> I wish to add a DSN to my 32-bit ODBC list programmatically but cannot
find
> any examples on how to do so.  I Would prefer a C or C++ solution.

> Thanks



Sat, 25 Nov 2000 03:00:00 GMT  
 I wish to add a DSN to my 32-bit ODBC List Programmatically

Quote:


> I wish to add a DSN to my 32-bit ODBC list programmatically but cannot find
> any examples on how to do so.  I Would prefer a C or C++ solution.

> Thanks

this works for me:

================================================
void COdbcinst2Dlg::OnButtonRegDatasource()
{
        // TODO: Add your control notification handler code here
        UpdateData();

        int nCurrpt,nCurLen;
        TCHAR Buffer[512];

        memset(Buffer,0,sizeof(Buffer));
        nCurrpt=0;

        CString szDSN("DSN=");
        nCurLen=szDSN.GetLength() * sizeof(TCHAR);
        memcpy(&Buffer[nCurrpt],szDSN,nCurLen);
        nCurrpt+=(nCurLen / sizeof(TCHAR));

        nCurLen= m_Edit_Register_Datasource.GetLength() * sizeof(TCHAR);
        memcpy(&Buffer[nCurrpt],m_Edit_Register_Datasource,nCurLen);
        nCurrpt+=(nCurLen / sizeof(TCHAR)) +1; // make one zero between srings

        CString szDescription("Description=Default Data Source");
        nCurLen=szDescription.GetLength() * sizeof(TCHAR);
        memcpy(&Buffer[nCurrpt],szDescription,nCurLen);
        nCurrpt+=(nCurLen / sizeof(TCHAR)) +1; // make one zero between srings

        CString szDatabase("Database=osk");
        nCurLen=szDatabase.GetLength() * sizeof(TCHAR);
        memcpy(&Buffer[nCurrpt],szDatabase,nCurLen);
        nCurrpt+=(nCurLen / sizeof(TCHAR)) +1; // make one zero between srings

        CString szDParam("DescribeParam=n");
        nCurLen=szDParam.GetLength() * sizeof(TCHAR);
        memcpy(&Buffer[nCurrpt],szDParam,nCurLen);
        nCurrpt+=(nCurLen / sizeof(TCHAR)) +1; // make one zero between srings

        LPCSTR  lpszDriver=m_Edit_Reg_Driver_Name;
        LPCSTR  lpszAttributes= (LPCSTR)&Buffer;

        BOOL
st=SQLConfigDataSource(NULL,ODBC_ADD_DSN,lpszDriver,lpszAttributes);
        m_EditStatus=st;

        UpdateData(FALSE);

Quote:
}



Sun, 26 Nov 2000 03:00:00 GMT  
 
 [ 7 post ] 

 Relevant Pages 

1. 32 bit app connects to 16 bit dsn

2. Retrieving a list of 32-bit ODBC datasources

3. 32-bit VC 2.2 DLLs with 32-bit VB4

4. top 32 bits of 64-bit product of two 32-bit integers

5. Linking 32 bit VC++4.2 DLLs with VB4.0 32 bit

6. 32-bit Excel 5.0 ODBC Driver

7. 32-bit Excel 5.0 ODBC Driver

8. 32 bit Icons and C# VS.net (24 bit + 8 bit alpha)

9. Porting Lotus 123 rel 5 add-in to 32 bit Lotus 123

10. signed 64bit (aka 32:32 bit) pseudo division and multiplication

11. 32-bit parallel crc-32 gen/chk with padding bytes

12. Add ODBC DSN in program?

 

 
Powered by phpBB® Forum Software