C Board  

Go Back   C Board > General Programming Boards > C# Programming

Reply
 
LinkBack Thread Tools Display Modes
Old 06-05-2003, 10:15 AM   #1
Registered User
 
Join Date: Feb 2002
Posts: 24
OLEDB Connection String to Excel

Hi there

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   Reply With Quote
Old 06-05-2003, 11:58 AM   #2
the hat of redundancy hat
 
nvoigt's Avatar
 
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   Reply With Quote
Old 06-06-2003, 03:06 AM   #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   Reply With Quote
Old 06-18-2003, 11:37 AM   #4
id id
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.
  Reply With Quote
Old 07-06-2003, 01:42 PM   #5
Registered User
 
datainjector's Avatar
 
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);
use the @ sigh before a string if u would like to ignore things like // /" etc ..instead you can just put them the way they should be typed in ....
__________________
"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   Reply With Quote
Reply

Thread Tools
Display Modes

Forum Jump

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


All times are GMT -6. The time now is 04:28 AM.


Powered by vBulletin® Version 3.8.1
Copyright ©2000 - 2009, Jelsoft Enterprises Ltd.
Search Engine Optimization by vBSEO 3.3.0 RC2

1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22