Solved

How to use SQLConfigDataSource ODBC API FUNCTION

Posted on 1998-08-04
2
774 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
[X]
Welcome to Experts Exchange

Add your voice to the tech community where 5M+ people just like you are talking about what matters.

  • Help others & share knowledge
  • Earn cash & points
  • Learn & ask questions
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

Industry Leaders: 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!

Question has a verified solution.

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

Suggested Solutions

Title # Comments Views Activity
ODBC Connection Logging, ADO.NET 6 73
deburging in oracle form 12 119
Detect CR LF to each line 12 185
Making an alias 7 121
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.
In a recent question (https://www.experts-exchange.com/questions/29004105/Run-AutoHotkey-script-directly-from-Notepad.html) here at Experts Exchange, a member asked how to run an AutoHotkey script (.AHK) directly from Notepad++ (aka NPP). This video…

734 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