Click here to Skip to main content
15,919,931 members
Home / Discussions / C#
   

C#

 
AnswerRe: [Message Deleted] Pin
Christian Graus25-Apr-09 22:59
protectorChristian Graus25-Apr-09 22:59 
QuestionHow to handle null values when reading array Pin
onetreeup25-Apr-09 10:23
onetreeup25-Apr-09 10:23 
AnswerRe: How to handle null values when reading array Pin
Christian Graus25-Apr-09 11:27
protectorChristian Graus25-Apr-09 11:27 
GeneralRe: How to handle null values when reading array Pin
onetreeup25-Apr-09 12:47
onetreeup25-Apr-09 12:47 
GeneralRe: How to handle null values when reading array Pin
Christian Graus25-Apr-09 13:24
protectorChristian Graus25-Apr-09 13:24 
AnswerRe: How to handle null values when reading array Pin
Luc Pattyn25-Apr-09 13:08
sitebuilderLuc Pattyn25-Apr-09 13:08 
AnswerRe: How to handle null values when reading array Pin
Sibugathulla25-Apr-09 17:52
professionalSibugathulla25-Apr-09 17:52 
QuestionCannot read .xls file - microsoft jet database engine could not find the object error Pin
dariusUK25-Apr-09 10:15
dariusUK25-Apr-09 10:15 
Hi there,

I'm trying to read .xls file using OleDb connection. I have two .xls files generated from SAP (actually these are Unicode text files saved as .xls) with two different names. When I execute my code I can only open one file, the second one gives an error:

System.Data.OleDb.OleDbException: The Microsoft Jet database engine could not find the object 'sheetName$'. Make sure the object exists and that you spell its name and the path name correctly.

Both files contains only one sheet which has the same name as the file itself. I've checked the spelling several times and even changed it manually but it doesn't work on one file. Even when I saved the file as proper Excel file. Here's the code I'm using:

//opens file and fills the DataGridView with data from file
string fileNameWithExt;
string fileNameWithoutExt;
int fileNameLength = 0;
int cutExtension = 4;
fileNameWithExt = openFileDialog1.SafeFileName;
fileNameLength = fileNameWithExt.Length;
fileNameWithoutExt = fileNameWithExt.Remove(fileNameLength - cutExtension);

OleDbConnection aConnection = new OleDbConnection(@"Provider=Microsoft.Jet.OLEDB.4.0;Data Source=c:\" + fileNameWithExt + ";Extended Properties=Excel 8.0");
aConnection.Open();

DataTable sampleDataTable = new DataTable();

//clears data table and dataGridView before creating a new one
dataGridView1.DataSource = null;
sampleDataTable.Clear();
sampleDataTable.Columns.Clear();

                    
OleDbDataAdapter oleDbCommand = new OleDbDataAdapter("Select * from ["+fileNameWithoutExt+"$]", aConnection);
oleDbCommand.Fill(sampleDataTable);


I hope somebody can point me in the right direction as I checked plenty of posts and know that something is wrong with the sheet name but can find the issue.

Regards,
AnswerRe: Cannot read .xls file - microsoft jet database engine could not find the object error Pin
Luc Pattyn25-Apr-09 10:29
sitebuilderLuc Pattyn25-Apr-09 10:29 
GeneralRe: Cannot read .xls file - microsoft jet database engine could not find the object error Pin
dariusUK26-Apr-09 7:15
dariusUK26-Apr-09 7:15 
GeneralRe: Cannot read .xls file - microsoft jet database engine could not find the object error Pin
Luc Pattyn26-Apr-09 11:07
sitebuilderLuc Pattyn26-Apr-09 11:07 
GeneralRe: Cannot read .xls file - microsoft jet database engine could not find the object error Pin
dariusUK27-Apr-09 11:11
dariusUK27-Apr-09 11:11 
GeneralRe: Cannot read .xls file - microsoft jet database engine could not find the object error Pin
dariusUK27-Apr-09 11:25
dariusUK27-Apr-09 11:25 
GeneralRe: Cannot read .xls file - microsoft jet database engine could not find the object error Pin
dariusUK27-Apr-09 11:29
dariusUK27-Apr-09 11:29 
GeneralRe: Cannot read .xls file - microsoft jet database engine could not find the object error Pin
Luc Pattyn27-Apr-09 11:51
sitebuilderLuc Pattyn27-Apr-09 11:51 
GeneralRe: Cannot read .xls file - microsoft jet database engine could not find the object error Pin
dariusUK28-Apr-09 10:59
dariusUK28-Apr-09 10:59 
Questionsetting height and width of controls in form Pin
mist_psycho25-Apr-09 6:34
mist_psycho25-Apr-09 6:34 
AnswerRe: setting height and width of controls in form Pin
fly90425-Apr-09 7:01
fly90425-Apr-09 7:01 
AnswerRe: setting height and width of controls in form Pin
Luc Pattyn25-Apr-09 7:07
sitebuilderLuc Pattyn25-Apr-09 7:07 
QuestionHow to make a program like Paint with C# Pin
MohammedMahmoud25-Apr-09 6:06
MohammedMahmoud25-Apr-09 6:06 
AnswerRe: How to make a program like Paint with C# Pin
Luc Pattyn25-Apr-09 6:23
sitebuilderLuc Pattyn25-Apr-09 6:23 
GeneralRe: How to make a program like Paint with C# Pin
MohammedMahmoud25-Apr-09 6:29
MohammedMahmoud25-Apr-09 6:29 
GeneralRe: How to make a program like Paint with C# Pin
Luc Pattyn25-Apr-09 6:33
sitebuilderLuc Pattyn25-Apr-09 6:33 
GeneralRe: How to make a program like Paint with C# Pin
MohammedMahmoud25-Apr-09 6:48
MohammedMahmoud25-Apr-09 6:48 
GeneralRe: How to make a program like Paint with C# Pin
MohammedMahmoud25-Apr-09 6:58
MohammedMahmoud25-Apr-09 6:58 

General General    News News    Suggestion Suggestion    Question Question    Bug Bug    Answer Answer    Joke Joke    Praise Praise    Rant Rant    Admin Admin   

Use Ctrl+Left/Right to switch messages, Ctrl+Up/Down to switch threads, Ctrl+Shift+Left/Right to switch pages.