Solved

How to use SQLConfigDataSource ODBC API FUNCTION

Posted on 1998-08-04
2
753 Views
Last Modified: 2013-11-19
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
Comment
Question by:adelchabbouh
2 Comments
 
LVL 3

Accepted Solution

by:
tma050898 earned 50 total points
Comment Utility
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
 

Author Comment

by:adelchabbouh
Comment Utility
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

Do You Know the 4 Main Threat Actor Types?

Do you know the main threat actor types? Most attackers fall into one of four categories, each with their own favored tactics, techniques, and procedures.

Join & Write a Comment

Suggested Solutions

Introduction: Finishing the grid – keyboard support for arrow keys to manoeuvre, entering the numbers.  The PreTranslateMessage function is to be used to intercept and respond to keyboard events. Continuing from the fourth article about sudoku. …
Introduction: The undo support, implementing a stack. Continuing from the eigth article about sudoku.   We need a mechanism to keep track of the digits entered so as to implement an undo mechanism.  This should be a ‘Last In First Out’ collec…
This video will show you how to get GIT to work in Eclipse.   It will walk you through how to install the EGit plugin in eclipse and how to checkout an existing repository.
You have products, that come in variants and want to set different prices for them? Watch this micro tutorial that describes how to configure prices for Magento super attributes. Assigning simple products to configurable: We assigned simple products…

772 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question

Need Help in Real-Time?

Connect with top rated Experts

9 Experts available now in Live!

Get 1:1 Help Now