Go Premium for a chance to win a PS4. Enter to Win

x
  • Status: Solved
  • Priority: Medium
  • Security: Public
  • Views: 795
  • Last Modified:

How to use SQLConfigDataSource ODBC API FUNCTION

I want to use SQLConfigDataSource ODBC API function to
add a data source dynamically without calling the setup dialog box

please give me a complete example with C++ or VISUAL BASIC
0
adelchabbouh
Asked:
adelchabbouh
1 Solution
 
tma050898Commented:
Here's an example of doing that with an Access database.

CString strAddDsn;
strAddDsn.Format("DSN=%s~DBQ=%s~UID=\"Admin\"~PWD=\"\"~Fil=MS Access~Exclusive=True~Readonly=False~~",
strDsn, strPathToFile);

char szDsn[255];
strcpy(szDsn, strAddDsn);
for (signed int i = strlen(szDsn) - 1; i >= 0; i--)
{
 if (szDsn[i] == '~')
 {
  szDsn[i] = 0x00;
 }
}

RETCODE rc = ::SQLConfigDataSource(NULL, ODBC_ADD_DSN, "Microsoft Access Driver (*.mdb)", szDsn);

0
 
adelchabbouhAuthor Commented:
This is for tma
 think you for our answer
It's my first time programing in VC++
can you give me please witch library Ihave to import
and witch .H files Ihave to include

think you.
0

Featured Post

Independent Software Vendors: We Want Your Opinion

We value your feedback.

Take our survey and automatically be enter to win anyone of the following:
Yeti Cooler, Amazon eGift Card, and Movie eGift Card!

Tackle projects and never again get stuck behind a technical roadblock.
Join Now