468,507 Members | 1,626 Online
Bytes | Developer Community
New Post

Home Posts Topics Members FAQ

Post your question to a community of 468,507 developers. It's quick & easy.

Accessing Excel Data in the Query using c# ,.net 2003 and sql 2000

I want to Open an excel sheet , then I want to loop through the rows in the excel sheet and should execute an update query for all the rows where the where condition in the query should match the columns of the excel sheet.
Eg:
Update Employee set Dept= AAA where employeenumbers= Excelsheet firstcolumn
So I want to loop this query for all the rows in the excel data.
The excel sheet will contain only employee numbers as the first column
The where condition can be for any columns in the excel sheet.
i have already opened the excel sheet using the OLEDB .
Sep 19 '07 #1
1 2918
Hi,

You mentioned that you are using OLEDB to open an excel file so i dont need to explain the details about it. to filter the information in your excel file and to fill the dataset with that filtered records you may copy the code below for your reference.

string strSheetName="Sheet1"
System.Data.OleDb.OleDbDataAdapter MyCommand
MyCommand = New System.Data.OleDb.OleDbDataAdapter("select * from [" + strSheetName + "$]", MyConnection)
DS = New System.Data.DataSet
MyCommand.Fill(DS)

Regards,
Ruel


I want to Open an excel sheet , then I want to loop through the rows in the excel sheet and should execute an update query for all the rows where the where condition in the query should match the columns of the excel sheet.
Eg:
Update Employee set Dept= AAA where employeenumbers= Excelsheet firstcolumn
So I want to loop this query for all the rows in the excel data.
The excel sheet will contain only employee numbers as the first column
The where condition can be for any columns in the excel sheet.
i have already opened the excel sheet using the OLEDB .
Sep 19 '07 #2

Post your reply

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

Similar topics

17 posts views Thread by Mansi | last post: by
1 post views Thread by Barbara Alderton | last post: by
3 posts views Thread by Ian Dunn | last post: by
By using this site, you agree to our Privacy Policy and Terms of Use.