Click here to Skip to main content
15,909,039 members
Please Sign up or sign in to vote.
0.00/5 (No votes)
See more: , +
hello,
i want to perform three steps

step1)
export datatble to excel sheet .
this step is completed.
excel sheet is fill with the datatable entry.

step2)
in this sheet there is column name status.
i want to check that status
from code behind which is written in excel sheet.
it can be change by user after save or open at time of export .

step 3)
and then after i want to update the that status in database.
after uploading that excel sheet. in browser
what should i do for the step 2 and step 3
plz tell me!
thank u!
Posted

to read the file in step 2 you can use the below piece of code:

C#
OleDbConnection connection = new OleDbConnection(@"Provider=Microsoft.Jet.OLEDB.4.0;Data Source=<<absolute path of the excel file including the file name>>;Extended Properties=Excel 8.0");
OleDbDataAdapter da = new OleDbDataAdapter("select * from <<sheet name in the file>>", connection );
DataTable dt = new DataTable();
da.Fill(dt);


Now you have all the data in a datatable.
You can validate the data and make changes as you want.

For step 3 you can make a procedure for updating the status column on a where clause.
You can call the procedure for every row of the datatable from the code
 
Share this answer
 
solve the problem

string oledbConnectionString = string.Empty;
OleDbConnection conn = null;
oledbConnectionString = "Provider=Microsoft.Jet.OLEDB.4.0; Data Source=" + filepath + "; Extended Properties=Excel 8.0;";
conn = new OleDbConnection(oledbConnectionString);
if (conn.State == ConnectionState.Closed)
{
conn.Open();
}
OleDbCommand command = new OleDbCommand("Select * from [sheet1$]", conn);
OleDbDataAdapter objAdapter = new OleDbDataAdapter();
objAdapter.SelectCommand = command;
DataSet objDataset = new DataSet();
objAdapter.Fill(objDataset, "Report");
conn.Close();
return objDataset.Tables[0];
 
Share this answer
 
v2
Comments
[no name] 28-Dec-11 5:25am    
solve the problem!!!!!!!!!!!!!!

This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)



CodeProject, 20 Bay Street, 11th Floor Toronto, Ontario, Canada M5J 2N8 +1 (416) 849-8900