473,382 Members | 1,639 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 473,382 software developers and data experts.

Need help: Importing from unsaved Excel file. Cannot find the activesheet.

I can import data from Excel using the following code if the spreadsheet is saved on the computer and has a non-empty path name:

string connStr = "Provider=Microsoft.Jet.OLEDB.4.0; Data Source=" + oXL.ActiveWorkbook.Path + "\\" + oXL.ActiveWorkbook.Name + ";" + "Extended Properties=Excel 8.0";

OleDbCommand cmdSelect = new OleDbCommand("SELECT * FROM [" + oSheet.Name + "$]", conn);

However, if the running instance of Excel is not saved on the computer and has an empty path name, I need to change the connection line to:

connStr = "Provider=Microsoft.Jet.OLEDB.4.0; Data Source=" + oXL.ActiveWorkbook.Name + ".xls;" + "Extended Properties=Excel 8.0";

After, when I try to execute the command, I get an error:

"The Microsoft Jet database engine could not find the object 'Sheet1$'. Make sure the object exists and that you spell its name and path name correctly."

My guess, it cannot find Sheet1 of the current instance of Excel because there is no path name. Any thoughts?
Feb 11 '08 #1
0 1102

Sign in to post your reply or Sign up for a free account.

Similar topics

1
by: c duden | last post by:
Excel won't allow documents to be linked to a worksheet in office 2000 when using C# to create an add-in. The following code snippets are what was used in the attempts (there are more...
1
by: v_verno | last post by:
Good day, I have a web page that shows info retrieved from a MySQL db and I would like to convert all these data into an .XLS file. Have searched the net high and low but seems that I'm unable to...
14
by: pmud | last post by:
Hi, I need to use an Excel Sheet in ASP.NET application so that the users can enter (copy, paste ) large number of rows in this Excel Sheet. Also, Whatever the USER ENETRS needs to go to the...
3
by: austin1539 | last post by:
I am trying to run an Access query from Excel. The query, called "ProdActs1" works in Access and is run from using information from a table called "Queries". When a button is clicked in Excel, data...
2
by: rajini | last post by:
Hai.... i have Vc++ code . i need to create Dll file by using following code can u help me....here with this i had sent my vc++ code VARIANT root = {0}; // Generic IDispatchs VARIANT...
3
by: Chris | last post by:
I have a python script that is driving Excel and using the win32com module. However, upon program completion there's still an Excel.exe process running in the background that I must terminate...
0
by: nphankey | last post by:
I'm struggling to tame Excel using Python and COM. Most of the following code is working except for the setting of the activesheet. Also, I would like to know how to release a COM object...
0
by: JFKJr | last post by:
I have an excel file, which has columns C and D grouped together, I am trying to delete blank columns and rows from the excel file, ungroup the columns and import the file to MS Access using Access...
1
by: CloudSolutions | last post by:
Introduction: For many beginners and individual users, requiring a credit card and email registration may pose a barrier when starting to use cloud servers. However, some cloud server providers now...
0
by: Faith0G | last post by:
I am starting a new it consulting business and it's been a while since I setup a new website. Is wordpress still the best web based software for hosting a 5 page website? The webpages will be...
0
by: Charles Arthur | last post by:
How do i turn on java script on a villaon, callus and itel keypad mobile phone
0
by: aa123db | last post by:
Variable and constants Use var or let for variables and const fror constants. Var foo ='bar'; Let foo ='bar';const baz ='bar'; Functions function $name$ ($parameters$) { } ...
0
by: ryjfgjl | last post by:
If we have dozens or hundreds of excel to import into the database, if we use the excel import function provided by database editors such as navicat, it will be extremely tedious and time-consuming...
0
by: ryjfgjl | last post by:
In our work, we often receive Excel tables with data in the same format. If we want to analyze these data, it can be difficult to analyze them because the data is spread across multiple Excel files...
0
by: emmanuelkatto | last post by:
Hi All, I am Emmanuel katto from Uganda. I want to ask what challenges you've faced while migrating a website to cloud. Please let me know. Thanks! Emmanuel
0
BarryA
by: BarryA | last post by:
What are the essential steps and strategies outlined in the Data Structures and Algorithms (DSA) roadmap for aspiring data scientists? How can individuals effectively utilize this roadmap to progress...
0
by: Hystou | last post by:
There are some requirements for setting up RAID: 1. The motherboard and BIOS support RAID configuration. 2. The motherboard has 2 or more available SATA protocol SSD/HDD slots (including MSATA, M.2...

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.