Answered by:
ODBC Connection String

Question
-
I'm trying to convince my boss to move the system to C# and SQL Server. So I thought I'd do a C# and access Demo (I will admit I made the mistake of ticking embedded database).
One of the things I wanted to show off was how easy it would be to do an error log, that would help us with clients, with every system I've built there has been an error log (I've worked with Access, SAP, Delphi, Pre .Net VB. C++ etc...), Error logging programs have never taken more than 30 Minutes to do!!! they are so easy. so in C# I created an error capture and sent it to my Error class in it's own Code File "sysSystems.cs", it took an hour to work out how to get the connection string (which should've been simple).
And when I did get it this is the error "ERROR [IM002] [Microsoft][ODBC Driver Manager] Data source name not found and no default driver specified"
This is the connection string "Provider=Microsoft.Jet.OLEDB.4.0;Data Source=|DataDirectory|\\ies.demo.mdb"
I Have been working on this error for 7 Hours I do not understand what i've done wrong. It dosn't really matter any more taking 8 hours to code something that has never taken more than 30 minutes is an absolute deal killer. But I would really like to know what I've done wrong.
PS in this I've incounted an error that has been posted about since 2005, 6 years later and it's still not fixed!! that is so sad and another nail in the coffin that says I'm wasting my time by posting this, but I really want to know.
Sunday, May 15, 2011 7:25 AM
Answers
-
Solved it myself!
I would like to thank you all for posting in response.
However I don't mean to be rude or nasty, but:
To the person who told me about the connection strings website, you must have missed the part were I said I got the connection string from the application (+ any simple search on the web would bring back that site, I had to delve deeper than that to find this site (Because I'd forgotten about it).
Most of you posted useful stuff but not to me.
I once had to (for sales reports for the boss) combine at least 3 different systems and databases. One of them was MYOB I know about ODBC and MYOB's ODBC, and this is were the problem was.
In my mind ODBC = "using system.data.odbc;" and anything with the odbc driver is included.
However for the people that actually looked at the connection string you would have seen OLEDB in it. I didn't even know about "using system.data.oledb;"
So Again thank you all, but read the original post!
- Marked as answer by Cookie Luo Friday, May 20, 2011 6:55 AM
Friday, May 20, 2011 6:03 AM
All replies
-
I would like to recommend using app.config as your connection string than hard coded. :)
Kindly read this, it might help you :)
http://www.dotnetperls.com/odbcconnection
Regards,
Eric
Failure is not the worst thing in the world. The very worst is not to try. Email Address : ericjohnadamos@gmail.comSunday, May 15, 2011 8:39 AM -
I'm trying to convince my boss to move the system to C# and SQL Server. So I thought I'd do a C# and access Demo (I will admit I made the mistake of ticking embedded database).
One of the things I wanted to show off was how easy it would be to do an error log, that would help us with clients, with every system I've built there has been an error log (I've worked with Access, SAP, Delphi, Pre .Net VB. C++ etc...), Error logging programs have never taken more than 30 Minutes to do!!! they are so easy. so in C# I created an error capture and sent it to my Error class in it's own Code File "sysSystems.cs", it took an hour to work out how to get the connection string (which should've been simple).
And when I did get it this is the error "ERROR [IM002] [Microsoft][ODBC Driver Manager] Data source name not found and no default driver specified"
This is the connection string "Provider=Microsoft.Jet.OLEDB.4.0;Data Source=|DataDirectory|\\ies.demo.mdb"
I Have been working on this error for 7 Hours I do not understand what i've done wrong. It dosn't really matter any more taking 8 hours to code something that has never taken more than 30 minutes is an absolute deal killer. But I would really like to know what I've done wrong.
PS in this I've incounted an error that has been posted about since 2005, 6 years later and it's still not fixed!! that is so sad and another nail in the coffin that says I'm wasting my time by posting this, but I really want to know.
Hello Bj RayHave a look at following
http://www.connectionstrings.com/
Should help you.
Hello
Carmelo La Monica http://community.visual-basic.it/carmelolamonica/Sunday, May 15, 2011 9:59 AM -
Hi,
1st of all, what is this name: ies.demo.mdb
It looks strange. Why do you have two names seperated with dot?
2nd of all, why you have two back slashes in the connection string "\\"? Try to replace it with only one back slash. Connectuon string has only one.
If this is not it, try to replace |DataDirectory| - which is a relative path to your db, with the full path, like:
"Provider=Microsoft.Jet.OLEDB.4.0;Data Source=C:\MyProject\YourDBName.mdb"
MitjaSunday, May 15, 2011 10:47 AM -
Please see my post here:
https://jqueryninja.wordpress.com/2011/01/10/how-do-i-get-the-connection-string/
Good luck.
Noam B.
Do not Forget to Vote as Answer/Helpful, please. It encourages us to help you...- Proposed as answer by Noam B Monday, May 16, 2011 10:50 AM
Sunday, May 15, 2011 11:25 AM -
Hi all
Thanks for your responses.
This is how I get the connection string:
(ConfigurationManager.ConnectionStrings["WindowsFormsApplication1.Properties.Settings.IES_DEMO"].ConnectionString);
This is what it says:
"Provider=Microsoft.Jet.OLEDB.4.0;Data Source=|DataDirectory|\\ies.demo.mdb"
And the error message is above.
I came across a thread (somewhere) with a similar problem, the final post was "Worked it out myself it was regional" didn't go into further details, since I'm in New Zealand, could this be my problem?
Tuesday, May 17, 2011 12:54 AM -
\ = Escape sequence charactor.
All strings with a path require a double back slash \\
Or strPath = @"c:\work\temp\...";
Two names:
IES = Integrated Electronic something or other.
Demo = Dynamic Extensive Modular, just kidding = Demonstration
I've tried replacing the |DataDirectory| with the actual directory.
I've tried the hardcoded string from the app.config file
And I've looked long and hard at the connection strings website
Tuesday, May 17, 2011 1:12 AM -
Hi
This error will occur if you do not have the correct ODBC driver installed suitable for your plugin type. For example, MYOB uses Visual Fox Pro, and as such MetriQ connects to MYOB's database using the ODBC connection bridge. If you get this error, first make sure that you have the plugin for the software you wish to export, installed. Next, make sure that Windows has registered the correct ODBC driver for this software.
To add an ODBC driver, go to the Control Panel and open Administrative Tools. Select Data Sources (ODBC). In the User DNS look for the driver suited to your Plugin.
If you cannot find this driver in the list, press Add. From the list provided, select the driver that your require. Press Finish. For the Data Source Name type the name of the driver you are configuring. Press OK. Leave the Data Source Administrator by pressing Apply.
Hope this can help you.
Have a nice day!
Cookie Luo[MSFT]
MSDN Community Support | Feedback to us
Get or Request Code Sample from Microsoft
Please remember to mark the replies as answers if they help and unmark them if they provide no help.
Wednesday, May 18, 2011 9:26 AM -
Solved it myself!
I would like to thank you all for posting in response.
However I don't mean to be rude or nasty, but:
To the person who told me about the connection strings website, you must have missed the part were I said I got the connection string from the application (+ any simple search on the web would bring back that site, I had to delve deeper than that to find this site (Because I'd forgotten about it).
Most of you posted useful stuff but not to me.
I once had to (for sales reports for the boss) combine at least 3 different systems and databases. One of them was MYOB I know about ODBC and MYOB's ODBC, and this is were the problem was.
In my mind ODBC = "using system.data.odbc;" and anything with the odbc driver is included.
However for the people that actually looked at the connection string you would have seen OLEDB in it. I didn't even know about "using system.data.oledb;"
So Again thank you all, but read the original post!
- Marked as answer by Cookie Luo Friday, May 20, 2011 6:55 AM
Friday, May 20, 2011 6:03 AM