a universal class to complete import data from an excel file into a database

How can i do that?
two file
one is update data to database

first step
i will define two sesion to write the operating table and operating columns in server.
two step
tell the customer where and how many columns they can update.


//get the data from excle
string strConn="Provider=Microsoft.Jet.OleDb.4.0;Data Source=d:\\收支表.XLS;Extended Properties=\"Excel 8.0;\"";
OleDbConnection conn=new OleDbConnection(strConn);
OleDbDataAdapter da=new OleDbDataAdapter("select * from [Sheet1$]",conn);
DataSet ds=new DataSet();
//import data to a dataset

//define sql Dataadapter
define a dataadapter
SqlDataAdapter adapter = new SqlDataAdapter();
adapter.SelectCommand = new SqlCommand(query, conn);

another is import data to database

posted on 2004-02-03 21:25  一望无际的南  阅读(746)  评论(0编辑  收藏  举报