Data Source: Programmatically Configuring an ODBC Data Source - HELP PLEASE

Data Source: Programmatically Configuring an ODBC Data Source - HELP PLEASE

Post by Mario Luiz Tortolano Arrud » Wed, 26 Nov 1997 04:00:00



OP: WIN95
COMPILER: VCPP 5.0 (SVP 2)

I have the above code, and I don't know why the "OPTION 1" does not work.
The contents of "p" in memory is the same as 2nd and 3rd line of the "OPTION
2" before the SQLConfigDataSource function.
Thanks, for any help.

char *p = new char[100];
char cCnt = 0;
memset(p,NULL,100);
CString strDummy = "DNS=TESTESQL";

for(char i=0;i<strDummy.GetLength();i++)
     p[cCnt++] = strDummy.GetAt(i);

p[cCnt++] = NULL;

strDummy = "DBQ=C:\\Projetos\\SRO_CPQD\\SOFTWARE\\PRS
TESTE\\PRS\\MDB\\sro.mdb";

for(i=0;i<strDummy.GetLength();i++)
     p[cCnt++] = strDummy.GetAt(i);
p[cCnt++] = NULL;
BOOL bRet = FALSE;
// ***** OPTION 1 *****
bRet = SQLConfigDataSource(NULL,ODBC_ADD_DSN,"Microsoft Access Driver
(*.mdb)",p);

// ***** OPTION 2 *****
bRet = SQLConfigDataSource(NULL,ODBC_ADD_DSN,"Microsoft Access Driver
(*.mdb)",
        "DSN=TESTESQL\0"
        "DBQ=C:\\Projetos\\SRO_CPQD\\SOFTWARE\\PRS
TESTE\\PRS\\MDB\\sro.mdb\0");