473,320 Members | 1,948 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,320 software developers and data experts.

Error when upload xlsx filein asp.net 'Sheet1$' is not a valid name.

I want to bind a .xlsx file to DropDownList.
From that I insert data into mysql database.

I have a connection string like this:

Expand|Select|Wrap|Line Numbers
  1. if(extencion==xlsx)
  2. {
  3.  
  4.   // excelConnectionString = "Provider=Microsoft.ACE.OLEDB.12.0;data source=" + filepath + ";extended Properties='Excel 12.0 Xml;HDR=YES;'";
  5.    excelConnectionString =    "Provider=Microsoft.ACE.OLEDB.12.0;Data source=" + filepath + ";Extended Properties='Excel 12.0 Xml;HDR=YES;'";
  6.  
  7. }
  8.  
  9.  
  10.  
  11. OleDbConnection excelConnection = new OleDbConnection(excelConnectionString);
  12. excelConnection.Open();
  13.  
  14. OleDbCommand testCmd = new OleDbCommand("Select count(*) from [Sheet1$]", excelConnection);
  15. string count = testCmd.ExecuteScalar().ToString();
  16. if (int.Parse(count) > 5001)
  17. {
  18.   //......
  19. }
  20.  
  21.  
I got this error:

'Sheet1$' is not a valid name. Make sure that it does not include invalid characters or punctuation and that it is not too long
Please help me
Dec 6 '12 #1
1 4917
PsychoCoder
465 Expert Mod 256MB
Are you sure there's a Sheet1$ in your Excel file?
Dec 6 '12 #2

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

Similar topics

1
by: H.L Bai | last post by:
hi, everybody i meet a parse error when i used the xml4c. any proposal is helpful. The error is following .../XMLRegionHandler.h:59 parse error before '*' .../XMLRegionHandler.h:60 parse...
5
by: lottaviano | last post by:
I am using Access 2002 and have two tables (Main and Actions) linked (in Relationships) on one field "CAL_ID" (primary key in Main Table). Main Table is a list of equipment. Actions Table lists...
6
by: Jim H | last post by:
I have an app I working on that was working fine a few days ago. Now I get a jscript error: Microsoft JScript runtime error: Object expected in a part of the code that has not been modifed or...
25
by: moondaddy | last post by:
I have an application where users need to upload images and in my web.config file I have a setting like this: <httpRuntime maxRequestLength="512" /> Which restricts image larger than 500k from...
12
by: Ann Marinas | last post by:
Hi all, I would like to ask for some help regarding separating the asp.net webserver and the sql server. I have created an asp.net application for a certain company. Initially, we installed...
0
by: SHPsalm139 | last post by:
We have a MS Access database which has VBA code to link to a .dbf file on a network drive using the following command: DoCmd.TransferDatabase acLink, "dBase IV", txtDBPath, acTable, ASTUTable &...
3
by: keithb | last post by:
Using a GridView, I get a "Specified cast is not valid" error when binding the Visible propery of a hyperlink control to a DataTable text field. The error goes away if I replace the data binding...
1
by: anbumozhip | last post by:
i have the following error when i trying to execute the page Warning: mysql_fetch_array(): supplied argument is not a valid MySQL result resource in C:\wamp\www\test\ouraction.php on line 14 ...
5
patjones
by: patjones | last post by:
Hi: I've got a backend database, with several tables linked together via one-to-many relationships, and a front end database that links to those tables. The problem is, when I attempt to look...
3
by: svsenthilkumar | last post by:
hai , i got an error in javascript, when upload a file in a form, the code is working properly in IE but i got javascript error in Mozilla firefos what is mean by error and how to rectify...
0
by: DolphinDB | last post by:
The formulas of 101 quantitative trading alphas used by WorldQuant were presented in the paper 101 Formulaic Alphas. However, some formulas are complex, leading to challenges in calculation. Take...
0
by: DolphinDB | last post by:
Tired of spending countless mintues downsampling your data? Look no further! In this article, you’ll learn how to efficiently downsample 6.48 billion high-frequency records to 61 million...
0
by: ArrayDB | last post by:
The error message I've encountered is; ERROR:root:Error generating model response: exception: access violation writing 0x0000000000005140, which seems to be indicative of an access violation...
1
by: PapaRatzi | last post by:
Hello, I am teaching myself MS Access forms design and Visual Basic. I've created a table to capture a list of Top 30 singles and forms to capture new entries. The final step is a form (unbound)...
0
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: Defcon1945 | last post by:
I'm trying to learn Python using Pycharm but import shutil doesn't work
0
by: Shællîpôpï 09 | last post by:
If u are using a keypad phone, how do u turn on JavaScript, to access features like WhatsApp, Facebook, Instagram....
0
by: af34tf | last post by:
Hi Guys, I have a domain whose name is BytesLimited.com, and I want to sell it. Does anyone know about platforms that allow me to list my domain in auction for free. Thank you
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...

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.