I just tried the path suggestion. I changed the path to "C:\\csharpdata\\Daily_Totals_By_Employee.xls". No change. At the risk of being obtuse, I don't understand how permissions could be the problem. I'm not saying you're all wrong, just that I don't understand it. The file is being opened: wouldn't a permissions issue prevent that? The program opens the file then fails to find the sheet.
mid_life_crisis
Posts
-
C# read of xls file works on Vista home premium but not XP Pro, Vista Business or 2003 server. [modified] -
C# read of xls file works on Vista home premium but not XP Pro, Vista Business or 2003 server. [modified]This is all the relevant code. I just don't get why it would work for the one system but not the others. string filename = "C:\\Program files\\Daily_Totals_By_Employee.xls"; string listname = "Sheet1"; OleDbConnection con = new OleDbConnection("Provider=Microsoft.Jet.OLEDB.4.0;Data Source=" + filename + ";Extended Properties = 'Excel 8.0'"); con.Open(); try { DataSet myDataSet = new DataSet(); OleDbDataAdapter myCommand = new OleDbDataAdapter(" SELECT * FROM [" + listname + "$]", con); myCommand.Fill(myDataSet); con.Close();
-
C# read of xls file works on Vista home premium but not XP Pro, Vista Business or 2003 server. [modified]Darn! Still no good. It makes no sense to me. Why fine on one but not on others? I used to say that I liked programming because of the instant gratification when you compile an app and it works, but this is an example of the dark counterpoint to that. Instant frustration.
-
C# read of xls file works on Vista home premium but not XP Pro, Vista Business or 2003 server. [modified]You are correct. Filename is a variable holding the full path of the actual file, and sheet1 does exist in all cases, as in each instance, I have copied the file from one to another. What is the "IMEX=1" all about?
-
C# read of xls file works on Vista home premium but not XP Pro, Vista Business or 2003 server. [modified]These are the relevent lines from the code. The same file is being opened, the problem is that the program can't find the sheet when running under XPPRo, 2003 server, or Vista Business. All computers are up to date with the latest .net installed, all have Excel 2003 with current updates. Any ideas? string listname = "Sheet1"; OleDbConnection con = new OleDbConnection("Provider=Microsoft.Jet.OLEDB.4.0;Data Source=" + filename + ";Extended Properties=Excel 8.0"); con.Open(); try { DataSet myDataSet = new DataSet(); OleDbDataAdapter myCommand = new OleDbDataAdapter(" SELECT * FROM [" + listname + "$]", con); myCommand.Fill(myDataSet); All Systems have Excel 2003 SP3 I get an error message on the failures: System.Data.OleDbException: The Microsoft Jet database engine could not find the object 'Sheet1$'
modified on Tuesday, February 17, 2009 12:14 PM