"Colin Stutley" wrote:
I now see your dilemma.
Not sure of the appropiate API calls, but an alternative may be to simple
add the appropiate registry entries for the DSN. I would try;
1) Export your registry to a disk file,
2) Create a new DSN with your desired properties via the control panel
applet,
3) Export your registry to a second disk file
Comparing the 2 export images should give you a snapshot of what registry
entries are being created, which you may then be able to insert via you .Net
app. Not "by the book" Im sure, but it may prove just as effective.
- Colin
"Lewt" wrote in messageColin, thanks for your quick response. I know all about the OLE stuff.
Yes, it works great. Unfortunately, some of us don't have the liberty of
being able to utilize that.
I am creating a deployment project in which I do not have control over the
source code for the original application. Unfortunately, for me, this app
uses ODBC DSNs to connect to multiple access databases. This means that on
the target computer I need the ability to create those DSNs - since asking
the user to figure out the ODBC Administrator is way too much to ask of the
users these days.
Please pardon me if I'm laying it on thick, but I've been scowering the
Internet looking for this missing link (between C# & the .NET framework and
this MFC? SQLConfigDataSoure function), but all I can find is several people
asking and responses of alternative methodologies.
I know it can be done - there is a company out there who has done it and
is selling the code. Unfortunately, I paid them the money and they ave not
delivered the code - legal proceedings may be forthcoming. In the meantime,
does anyone know how to do this? Thanks!!
-Lewt
"Colin Stutley" wrote:Have you looked at OLEDb rather than ODBC?
To get to your access database you could establish a connection via;
string vConStr = "Provider=Microsoft.Jet.OLEDB.4.0;"
+ "Data Source=C:\\Testdb.mdb;"
+ "User ID=Admin;Password=MyPassword;" // optional
+ "Jet OLEDB:Database Password=DevId"; //optional
System.Data.OleDb.OleDbConnection vDatabase = new OleDbConnection(vConStr); vDatabase.Open();
The ODBC and OLEDb methods are very similar from this point on.
OR
If you already have the MSAccess ODBC drivers installed you do not need to create a specific DSN for your individual connection. eg,
string vConStr = "Driver={Microsoft Access Driver (*.mdb)};"
+ "DBQ=C:\\Testdb.mdb;UID=;PWD=;";
System.Data.Odbc.OdbcConnection vDatabase = new OdbcConnection(vConStr);
- Colin.
"Lewt" wrote in message
> I am also interested in a detailed description of this... I have read
everything I can find on the SQLConfigDataSource function. Does anyone know how to implement this within C#.net - (i.e. add a MS Access DSN to System DSNs)? Thanks!
> -Lewt
>