C# Tutorials and offshore development in India
    Tutorials   Resources   Forum   Communities   Interview   Jobs   Projects   Offshore Development    
Silverlight Tutorials | Mentor | Code Converter | Articles | Code Factory | Computer Jokes | Members | Peer Appraisal | IT Companies | Bookmarks | Revenue Sharing |


Prizes & Awards
My Profile



Active Members
TodayLast 7 Days more...

New Feature: Community Sites: Create your own .NET community website and start earning from Google AdSense ! It's Free !




Reading Excel with OleDB


Posted Date: 10 Oct 2008      Total Responses: 1

Posted By: Toral       Member Level: Bronze     Points: 1


Hi
I am creating one application where in I am reading excel sheet. I am reading the sheet using OleDB. Somehow it is not reading one coulumn.
I have added IMEX = 1; also. But still no luck. Please guide me.




Responses

Author: Rex Sahaya Gregory    15 Oct 2008Member Level: BronzeRating:     Points: 6
string connectionString = @"Provider=Microsoft.Jet.
OLEDB.4.0;Data Source=Book1.xls;Extended
Properties=""Excel 8.0;HDR=YES;""";

DbProviderFactory factory =
DbProviderFactories.GetFactory("System.Data.OleDb");

DbDataAdapter adapter = factory.CreateDataAdapter();

DbCommand selectCommand = factory.CreateCommand();
selectCommand.CommandText = "SELECT ID,City,State
FROM [Cities$]";

DbConnection connection = factory.CreateConnection();
connection.ConnectionString = connectionString;

selectCommand.Connection = connection;

adapter.SelectCommand = selectCommand;

DataSet cities = new DataSet();

adapter.Fill(cities);

gridEX1.SetDataBinding(cities.Tables[0], "");
gridEX1.RetrieveStructure();



Post Reply
You must Sign In to post a response.
Next : Active Directory Security
Previous : How integrate gears into dotnet webbrowser
Return to Discussion Forum
Post New Message
Category: .NET

Related Messages



dotNet Slackers   BizTalk Adaptors    Web Design

it support

Contact Us    Privacy Policy    Terms Of Use