怎样从excel中导出的数据集插入到数据库中
string strConn = "Provider=Microsoft.Jet.OLEDB.4.0;" + "Data Source=" + Path+ ";" + "Extended Properties=Excel 8.0;";
OleDbConnection conn = new OleDbConnection(strConn);
conn.Open();
string strExcel = "";
OleDbDataAdapter myCommand = null;
set.Clear();
strExcel = "select * from [Sheet1$] ";
myCommand = new OleDbDataAdapter(strExcel, strConn);
myCommand.Fill(set, "Sheet1");
这段代码是从excel中导出数据到dataset里面的,现在问题是我想把dataset里面的数据插入到数据库里面啊,该怎么插入啊?
最好给代码来,很急啊。
------解决方案--------------------
excel可以直接导入到数据库中
请看我的blog http://www.cnblogs.com/mqcan/archive/2008/03/07/1095361.html
------解决方案--------------------
SQL code
SELECT * into newtable
FROM OpenDataSource( "Microsoft.Jet.OLEDB.4.0",
"Data Source="c:\book1.xls";User ID=Admin;Password=;Extended properties=Excel 5.0").[Sheet1$]
------解决方案--------------------
参考
http://www.fh888.com/showfile.html?articleid=D624F645DDF54DFE847C0092F812D9E4&projectid=5&username=yhn