![]() |
| | #1 |
| Registered User Join Date: Feb 2002
Posts: 24
| OLEDB Connection String to Excel Im trying to connect to the DB using oleDb . I am tryign to connect to an Excel DB Based on all sources I could find on the net, the connection string has to be "Provider=Microsoft.Jet.OLEDB.4.0;Data Source=C:\MyExcel.xls;Extended Properties=""Excel 8.0;HDR=Yes;IMEX=1""" explanation: "HDR=Yes;" indicates that the first row contains columnnames, not data "IMEX=1;" tells the driver to always read "intermixed" data columns as text Text So, in my program, Im writing ===> OleDbConnection conn = new OleDbConnection("Provider=Microsoft.Jet.OLEDB.4.0; Data Source=C:\\xl.xls;Extended Properties=\"Excel 8.0\";\"HDR=Yes;IMEX=1\"\""); I keep getting an exception saying that "Format of the initialization string does not conform to the OLE DB specification. Starting around char[102] in the connection string What am I doing wrong?
__________________ And if you get no joy from music hall Remember there is always alcohol And If you get no joy from Gin Here is the abyss jump in |
| gozlan is offline | |
| | #2 |
| the hat of redundancy hat Join Date: Aug 2001 Location: Hannover, Germany
Posts: 2,754
| Why do you have 2 double quotes at the end of your string ? Try a single double quote...
__________________ hth -nv She was so Blonde, she spent 20 minutes looking at the orange juice can because it said "Concentrate." When in doubt, read the FAQ. Then ask a smart question. |
| nvoigt is offline | |
| | #3 |
| Registered User Join Date: Feb 2002
Posts: 24
| no. it doesn't do the trick....Still getting an exception
__________________ And if you get no joy from music hall Remember there is always alcohol And If you get no joy from Gin Here is the abyss jump in |
| gozlan is offline | |
| | #4 |
| Guest
Posts: n/a
| There are no double quotes required between Excel 8.0 and HDR=Yes (your first one is correct!). Remove bold bits: ("Provider=Microsoft.Jet.OLEDB.4.0;Data Source=C:\\xl.xls;Extended Properties=\"Excel 8.0\";\"HDR=Yes;IMEX=1\""); Don't kick yourself as I had to go through char by char between your one and a working one I use to find the error. |
|
| | #5 |
| Registered User Join Date: Mar 2002
Posts: 354
| Code: OleDbConnection conn = new OleDbConnection(@"Provider=Microsoft.Jet.OLEDB.4.0;Data Source=C:\xl.xls;Extended Properties= Excel 8.0;"HDR=Yes;IMEX=1);
__________________ "I wish i could wish my wishs away" "By indirections find directions out" -- William Shakespears "Do what thou wilt shall be the whole of the law" -- Crowley "THE BEAST 666" Mizra -> love = Death... RDB(Rocks yooo).. http://www.cbeginnersunited.com Are you ready for the Trix ??? |
| datainjector is offline | |
![]() |
| Thread Tools | |
| Display Modes | |
|
Similar Threads | ||||
| Thread | Thread Starter | Forum | Replies | Last Post |
| char Handling, probably typical newbie stuff | Neolyth | C Programming | 16 | 06-21-2009 04:05 AM |
| Inheritance Hierarchy for a Package class | twickre | C++ Programming | 7 | 12-08-2007 04:13 PM |
| RicBot | John_ | C++ Programming | 8 | 06-13-2006 06:52 PM |
| Classes inheretance problem... | NANO | C++ Programming | 12 | 12-09-2002 03:23 PM |
| Warnings, warnings, warnings? | spentdome | C Programming | 25 | 05-27-2002 06:49 PM |