我是新手,往数据库导入excel固定表格,显示导入成功后,数据库里没有反应,好像只上传到服务器了,怎么弄到数据库中
if (FileUpload1.HasFile==false)
{
Response.Write("<script>alert('请选择文件!')</script>");
return;
}
string isXSL = System.IO.Path.GetExtension(FileUpload1.FileName).ToString().ToLower(); //获取文件的扩展名
if (isXSL!=".xls")
{
Response.Write("<script>alert('请选择Excel文件!')</script>");
return;
}
string filename = FileUpload1.FileName;
string savePath = Server.MapPath("upfiles\\") + filename;
FileUpload1.SaveAs(savePath);
DataSet ds = ExcelSqlConnection(savePath,filename);
DataRow[] dr = ds.Tables[0].Select(); //定义一个DataRow数组
int rowsnum = ds.Tables[0].Rows.Count;
if (rowsnum == 0)
{
Response.Write("<script>alert('Excel表为空表,无数据!')</script>"); //当Excel表为空时,对用户进行提示
}
else{
for (int i = 0; i < dr.Length;i++ )
{
string studentID = dr[i]["学号"].ToString();
string name = dr[i]["姓名"].ToString();
string courseName = dr[i]["课程名称"].ToString();
string credit = dr[i]["学分"].ToString();
string psScore = dr[i]["平时成绩"].ToString();
string qzScore = dr[i]["期中成绩"].ToString();
string qmScore = dr[i]["期末成绩"].ToString();
string syScore = dr[i]["实验成绩"].ToString();
string endScore = dr[i]["总评成绩"].ToString();
&nb