62,051
社区成员
发帖
与我相关
我的任务
分享
SqlConnection con = new SqlConnection(ConfigurationManager.AppSettings["conStr"]);
con.Open();
string sql = @" INSERT INTO Table1 SELECT * FROM OpenRowSet ('microsoft.jet.oledb.4.0','Excel 8.0; HDR=NO;IMEX=1;database=Products.xls;','select * from [sheet1$]') ";
SqlCommand cmd = new SqlCommand(sql, con);
int line= cmd.ExecuteNonQuery();
if(line>0)
{
Response.Write("<script>alert('成功')</script>");
}