Problem when get data from Excel file using ADO.NET


Private Sub GetDataFromXLS()
Dim strConn As String
Dim objConn As OleDbConnection
Dim sql As String
strConn = _
"Provider=Microsoft.Jet.OLEDB.4.0; " & _
"Data Source=C:\Data.xls;" & _
"Extended Properties=Excel 8.0;HDR=Yes;"
objConn = New OleDbConnection(strConn)
sql = "SELECT ProductCode, ProductName FROM [Data$]"
'-Data is name of sheet in Data.xls.
Dim objCommand As New OleDbCommand(sql, objConn)
Dim objAdapter As New OleDbDataAdapter(objCommand)
Dim objDS As New DataSet
With Me.gridProduct
.DataSource = objDS.Tables(0).DefaultView
End With
End Sub
I use Excel 2003.
[red]I don't understand where's wrong in above, but it showed error following:
Line 50: strConn = "Provider=Microsoft.Jet.OLEDB.4.0;Data Source=C:\Data.xls;Extended Properties=Excel 8.0;HDR=Yes;"
Line 51: objConn = New OleDbConnection(strConn)
Line 52: objConn.Open()
Line 53:
Line 54: sql = "SELECT ProductCode, ProductName FROM [Data$]"[/red]
Please help me in this situation.
Thank you alot.
1/17/2005 7:43:13 AM 16182 articles. 0 followers. Follow

1 Replies

Similar Articles

[PageSpeed] 41

The ASPNET user does not likely have rights to read in the c:\ folder.
Starting with ASP.NET 2.0? Look at:
Programming Microsoft Web Forms
My Blog
1/17/2005 2:42:40 PM

Similar Artilces:

Problem with Reading Data from Excel using ADO.NET
Hi, I am trying to read data from Excel and import into my ASP.NET web application. This runs perfect on my local computer (in debug mode), but does not run when I deploy it to the test/production environment. First, I got the Unexpected exception, which I solved by providing access to ASPNET account on the TEMP folders. Now I continue to get this error while trying to run the code on the server. I 've tried with worksheets, ranges, nothing seems to work on the server, but locally there's no problems. The error is: The Microsoft Jet Database Engine could not find the Obj...

how to get data from excel using
how to get data from excel using Hi, This article might help: Regards, How can obtain the sheet's list of a Excel document? here u can find the solution for your problem, mark if as answer if u problem got solved  Vyas ...

How to access data using objects onkeypress event
Hi there, Onkeypress event of a textbox, I want to query database using my already existing database connection ( i'm using Now I did not find anyway to write VB code to trap onkeypress event. The only way I found was to write a javascript. But in javascript, I was not able to access my exitsting data object like connection and dataset. As in my case I need to query only from current database session as my transaction is not over yet. Can anybody Please suggest me some way to do this. This is very very urgent and important for me. onkeypress is a "client side ev...

Sending SMS using or using or
Hi  My requirement is I hav one csv file with these fields id,mobilenum,messgae,status.intiallu staus is 0. once i read the all fileds and take that mobile number.using tat mobile number  i need to send sms .after sending sms i shuld change status as 1 How to send sms thru coding (please dont provide any links.if it is provide also please give working links becox i checked codeproject .i didnt get any nice link. and also provide the how to update the status field im csv file   Thank ssandhya   To send SMS, you need some third party SMS providers. if you consul...

how to populate data into a preformatted excel file which contains macros using
Want to populate data into a preformatted excel file which contains macros using to populate data into an normal excel file using interopservices and using the excel COM object.But not able to use the same for populating data into a preformatted excel file which contains macros.Help me on this.Thanks in advance If you are trying to populate the data from SQL Server into MS Excel, you could consider using DTS (Data Transformation Services) and running this as service and calling it from your application.Regards, Narayana Rao Surapaneni Architect | Author | MCSD for .NET | MCSD ...

Pls Help Append Data/Image in an existing excel file using
hi  I am using following code to write an graph image in an excel file .I want to write append this data/image in an existing excel file containing different report data.The below code doesn't work.If i use instead of filemode.append then it writes in the file. what am i doing wrong is it something i m trying that is not possible or incorrect any advice will be helpfull.pls help me Thanks Shalin fs = New FileStream(Server.MapPath("TempExcel/test.xls"), FileMode.Create) fs.Write(bytes, 0, bytes.Length) fs.Close() fsRead = New FileStream(Server.MapPath("TempExcel/te...

How to get datasource name dynamically from .txt / .xml file using 2.0 with Mysql 5.0
I am using C#.Net 2.0 With MySql 5.0. I created a project and it works fine in my machine. But problem occurs when i try to run the project other than my machine. I wrote datasource=mysystem name in connection string. Is it possible to get datasource name dynamically from a text file (*.txt) or from .xml file for MySql.Regards,Tamizhselvi  Add an App.Config file to your project and you can drop a connection string in there like so:  <connectionStrings>    <add name="PICK A NAME" connectionString="YOUR CONNECTION STRING"/>...

How to Create .mdb file from Excel file using
Hi all I want to create .mdb file that i have created excel feel from MS jet Database... through code behind Help me in this..  Regards RaviPlease click "mark as answer" if this post helped you. How to create an mdb file programmtically: to import Excel data into it: Regards Mike [MVP - ASP/ASP.NET]My site...

ADO.Net for Excel files
I wrote a windows form application in C# that uses ADO.Net to read from an Excel file. I receive xls files but have to manually save them as xlsx files because I can't get the program to read xls files (I get "External table is not in the expected format"). As an aside, for broadest .net compatibility, I set each of the Projects (which create assemblies/dlls) for the application to .net framework 2.0. I have 2 questions: 1. How can I get my program to read xls files when Excel 2007 is installed? 2. How can I support environments where Excel 2002 and Excel 2003 are installe...

Can I use ADO.NET Data Services with Dynamic Data Websites?
I would like to use Dynamic Data Websites with the proxy class generated from WebDataGen.exe.  Is this possible?  Also, does the SchemaCreator class support the Provider model? In the current CTP, Dynamic Data only supports Linq To Sql models.  In th next release, it will also support Entity Framework models.  However, it won't directly support ADO.NET data services, though we are looking at this scenario for a later release. thanks,David...

which is shou i use? Microsoft .NET Framework 1.1 Data Provider for Oracle and the Oracle Data Provider for .NET
Microsoft .NET Framework 1.1 Data Provider for Oracle and the Oracle Data Provider for .NETI am confused?Which is better or which one should I use?BTW, I am going to use .net 2.0 with oracle 9. Can anyone tell me what shou I use for working with oracle database?Thanks very much in advance!Justin Oracle's data provider has more functionality than Microsoft's.If your doing transaction processing you can have SAVEPOINTs, which Microsoft's data provider does not provide.Also, Oracle has PL/SQL Associative Arrays which are very powerful.Oracle also allows you to bind parameters by name and pos...

How to Data Transfer From Excel to Microsoft SQL Server Data base Using .Net.
Hai All, How to Data Transfer From Excel to Microsoft SQL Server Data base Using .Net. I have one Excel Sheet in that sheet 15 Fields (attributes) and 3000 records are there. In this 3000 records i want to store this (Excel) data into  5 related tables on Sql Server Database Using .Net.   How to store Excel Sheet data into Sql Server database. Please help me as soon as possible. Thank You Very Much...Have a Good Day... With RegardsSridhar...

.Net 2.0 Web application using is unable to create object of another dll writen in C# .net 2.0
Hi, I habe created one web application using which is adding reference of dlls written in C# and .net 2.0. But whenever trying to create object of referencing dll, it is throwing error :Object reference does not set to an object. But, locally it is working fine,. In the server i have deployed the .aspx files and dll files in the bin. There were already an web.config in the server which is of .net 1.1. But checked it is retrieving value for that web.config correctly. Should i have to deply any other files and if not what can be the solution for this? Please help. Thanks, So...

Insert datetime, using
Hello there,I got a little code there are inserting a record into my msSQL database..But i cant insert the datetime, for one reason?The problem is in line 7 () where i want to insert DateTime.Now 1 Protected Sub SendPmTilAfviste(ByVal modtager As String, ByVal festID As String) 2 ' Connection 3 Dim conn As SqlConnection = New SqlConnection("Data Source=.\SQLEXPRESS;AttachDbFilename=|DataDirectory|\ASPNETDB.MDF;Integrated Security=True;User Instance=True") 4 conn.Open() 5 6 ' SQL-kommandoen 7 Dim cm...

Web resources about - Problem when get data from Excel file using ADO.NET -

Is–ought problem - Wikipedia, the free encyclopedia
The is–ought problem in meta-ethics as articulated by Scottish philosopher and historian David Hume (1711–76) is that many writers make claims ...

iOS 9.2 ‘might’ fix the blackout problem some iPad Pros have, says Apple
... iOS Devices Check out 9to5Mac for more breaking coverage of iOS Devices . What do you think? Discuss "iOS 9.2 ‘might’ fix the blackout problem ...

Apple suggests iOS 9.2 will fix unresponsive iPad Pro problem
... by pressing and holding the Sleep/Wake and Home button for 10 seconds, until the Apple logo appears. With the release of iOS 9.2, that problem ...

FBI Director: Silicon Valley’s encryption is a “business model problem”
... attacks in Paris and California. Today, FBI director James Comey has suggested that Silicon Valley isn't faced with a serious technical problem, ...

Has Spotify found the perfect solution to its Adele problem?
It's official: Taylor Swift called Spotify's bluff . On Tuesday, The Wall Street Journal reported that Spotify is planning to allow some artists ...

Sure, he's a problem. But not so much that they can't make the best of it.
Sure, he's a problem. But not so much that they can't make the best of it. by digby Here's a little reminder about where the GOP is really heading ...

The FBI director just gave a striking example of how much of a problem encryption has become
... serious the issue has become. At a Senate Judiciary Committee hearing on Wednesday, FBI Director James Comey said encryption is a "big problem" ...

VW: CO2 emissions problem far smaller than suspected
Company says "slight deviations" were found in nine variants of VW brand models, including the Jetta, Golf and Passat

The Big Problem With Star Wars, According To Francis Ford Coppola
Cinema Blend The Big Problem With Star Wars, According To Francis Ford Coppola Cinema Blend Even though he had nothing to do with the actual ...

Can Cisco fix workplace video problem?
Cisco has spent decades building products for IT managers and engineers. It's now trying to adopt a consumer mentality.

Resources last updated: 12/11/2015 4:42:38 AM