Home | Contact Us | FAQ | Search & Site Map | Link to Us
Sign In | Join | Other 45 Sites in Network
Home
DiscussionsAccessExcelInfoPathOutlookPowerPointPublisherWord
DirectoryUser Groups
Related Topics
Outlook ExpressInternet ExplorerWindowsMS Server ProductsMore Topics ...

MS Office Forum / Excel / Programming / April 2008

Tip: Looking for answers? Try searching our database.

OleDb Excel 12.0 bug

Thread view: 
Enable EMail Alerts  Start New Thread
Thread rating: 
Anton - 15 Apr 2008 18:02 GMT
Hi,

I seem to have found a bug for which there seems not to be a workaround. The
following code will throw an exception, but if you change and use xls (even
using the new driver), it works.
Is there a workaround?

string constring = "Provider=Microsoft.ACE.OLEDB.12.0;Data
Source=d:\\inetpub\\test.xlsx;Extended Properties=\"Excel 12.0
Xml;HDR=YES;\"";
//string constring = "Provider=Microsoft.Jet.OLEDB.4.0;Data
Source=d:\\inetpub\\test.xls;Extended Properties=\"Excel 8.0;HDR=Yes;\"";

OleDbConnection oleDBConnection = new OleDbConnection(constring);
oleDBConnection.Open();

OleDbDataAdapter dataAdapter = new OleDbDataAdapter();
try
{
    string createTable = "CREATE TABLE [Export] (test1 LONGTEXT,test2
LONGTEXT);";
    OleDbCommand comOleDBCommand = new OleDbCommand(createTable,
oleDBConnection);
    comOleDBCommand.ExecuteNonQuery();
   
    string insertData = "INSERT INTO [Export$] (ddddd, test2)
VALUES('Florida','Share ideas, and get advice and assistance from fellow
Microsoft Office userss your community, and its all here. Make Office work
for you and interact with other users by participating in these
newsgroups.Share ideas, and get advice and assistance from fellow Microsoft
Office users—its your community, and its all here. Make Office work for you
and interact with other users by participating in these newsgroups.')";
    OleDbCommand command = new OleDbCommand(insertData, oleDBConnection);

    command.ExecuteNonQuery();
}
finally
{
    oleDBConnection.Dispose();
}
Anton - 15 Apr 2008 18:16 GMT
Make that:
string constring = "Provider=Microsoft.ACE.OLEDB.12.0;Data
Source=d:\\inetpub\\test.xlsx;Extended Properties=\"Excel 12.0
Xml;HDR=YES;\"";
//string constring = "Provider=Microsoft.Jet.OLEDB.4.0;Data
Source=d:\\inetpub\\test.xls;Extended Properties=\"Excel 8.0;HDR=Yes;\"";

OleDbConnection oleDBConnection = new OleDbConnection(constring);
oleDBConnection.Open();

OleDbDataAdapter dataAdapter = new OleDbDataAdapter();
try
{
    string createTable = "CREATE TABLE [Export] (test1 LONGTEXT,test2
LONGTEXT);";
    OleDbCommand comOleDBCommand = new OleDbCommand(createTable,
oleDBConnection);
    comOleDBCommand.ExecuteNonQuery();

    string insertData = "INSERT INTO [Export$] (test1, test2)
VALUES('Florida','Share ideas, and get advice and assistance from fellow
Microsoft Office userss your community, and its all here. Make Office work
for you and interact with other users by participating in these
newsgroups.Share ideas, and get advice and assistance from fellow Microsoft
Office users—its your community, and its all here. Make Office work for you
and interact with other users by participating in these newsgroups.')";
    OleDbCommand command = new OleDbCommand(insertData, oleDBConnection);

    command.ExecuteNonQuery();
}
finally
{
    oleDBConnection.Dispose();
}
 
Sign In
Join
My Latest Posts
My Monitored Threads
My Blog
My Photo Gallery
My Profile
My Homepage

Start New Thread
Enable EMail Alerts
Rate this Thread



©2008 Advenet LLC   Privacy Policy - Terms of Use
This website includes both content owned or controlled by Advenet as well as content owned or controlled by third parties.