C# 怎么把一个excel导入到SQL里面去?
2个回答
展开全部
将Excel的数据导入SQL server :
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$]
实例:
SELECT * into newtable
FROM OpenDataSource( 'Microsoft.Jet.OLEDB.4.0',
'Data Source="c:\Finance\account.xls";User ID=Admin;Password=;
Extended properties=Excel 5.0')...xactions
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$]
实例:
SELECT * into newtable
FROM OpenDataSource( 'Microsoft.Jet.OLEDB.4.0',
'Data Source="c:\Finance\account.xls";User ID=Admin;Password=;
Extended properties=Excel 5.0')...xactions
追问
能否给一个案例下载地址?
2016-06-13
展开全部
string strPath = "provider=microsoft.jet.oledb.4.0;extended properties=excel 8.0;data source="+Server .MapPath ("1.xls");
OleDbConnection conn = new OleDbConnection(strPath);
conn.Open();
OleDbCommand cmd = new OleDbCommand("select * from [sheet1$]", conn);
OleDbDataAdapter da = new OleDbDataAdapter(cmd);
DataTable dt = new DataTable();
da.Fill(dt);
OleDbConnection conn = new OleDbConnection(strPath);
conn.Open();
OleDbCommand cmd = new OleDbCommand("select * from [sheet1$]", conn);
OleDbDataAdapter da = new OleDbDataAdapter(cmd);
DataTable dt = new DataTable();
da.Fill(dt);
追问
能给个案例下载地址吗?
已赞过
已踩过<
评论
收起
你对这个回答的评价是?
推荐律师服务:
若未解决您的问题,请您详细描述您的问题,通过百度律临进行免费专业咨询