Solved

How to use SQLConfigDataSource ODBC API FUNCTION

Posted on 1998-08-04
2
760 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
ID: 1320183
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
ID: 1320184
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

Best Practices: Disaster Recovery Testing

Besides backup, any IT division should have a disaster recovery plan. You will find a few tips below relating to the development of such a plan and to what issues one should pay special attention in the course of backup planning.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

Suggested Solutions

Title # Comments Views Activity
Need a Shell script to start a service checking the port 6 50
Expand LInux Boot partition remotly 3 90
sum28 challenge 31 112
JQuery serialize and unserialize 8 85
Here is how to use MFC's automatic Radio Button handling in your dialog boxes and forms.  Beginner programmers usually start with a OnClick handler for each radio button and that's just not the right way to go.  MFC has a very cool system for handli…
This is to be the first in a series of articles demonstrating the development of a complete windows based application using the MFC classes.  I’ll try to keep each article focused on one (or a couple) of the tasks that one may meet.   Introductio…
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.
The Email Laundry PDF encryption service allows companies to send confidential encrypted  emails to anybody. The PDF document can also contain attachments that are embedded in the encrypted PDF. The password is randomly generated by The Email Laundr…

777 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