日期:2014-05-18  浏览次数:20909 次

急求啊,在线等啊!!!!各位达人帮忙!!!下午就要交了!!!帮帮我!!

  private DataSet GetExcelDs()
  {
  string strConn = "Provider=Microsoft.Jet.OLEDB.4.0;Data Source=" + Path + ";Extended Properties=Excel 8.0";
  //链接Excel
  OleDbConnection cnnxls = new OleDbConnection(strConn);
  //读取Excel里面有 表Sheet1
  OleDbDataAdapter oda = new OleDbDataAdapter("select * from [Sheet1$]", cnnxls);
  DataSet dsUpdate = new DataSet();
  //将Excel里面有表内容装载到内存表中!
  oda.Fill(dsUpdate, "newtable");
  return dsUpdate;
  }



  private void btnUpdateMany_Click(object sender, EventArgs e)
  {
  try
  {
  DataSet dsUpdate = this.GetExcelDs();
  da.UpdateCommand = new SqlCommand("sp_updateSngCode", conn);
  da.UpdateCommand.Parameters.Add("@loginName", SqlDbType.NVarChar, 50, "LoginName");
  da.UpdateCommand.Parameters.Add("@loginPass", SqlDbType.NVarChar, 50, "LoginPass");
  da.UpdateCommand.Parameters.Add("@trueName", SqlDbType.NVarChar, 50, "TrueName");
  da.UpdateCommand.Parameters.Add("@Ugroup", SqlDbType.NVarChar, 50, "Ugroup");
  da.UpdateCommand.Parameters.Add("@email", SqlDbType.NVarChar, 50, "Email");
  da.UpdateCommand.Parameters.Add("@wYPXJL", SqlDbType.NVarChar, 2000, "WYPXJL");
  da.UpdateCommand.Parameters.Add("@mobile", SqlDbType.NVarChar, 50, "Mobile");
  da.UpdateCommand.Parameters.Add("@tel", SqlDbType.Int, 50, "Tel");
  da.UpdateCommand.CommandType = CommandType.StoredProcedure;
  conn.Open();
  da.Update(dsUpdate.Tables["newtable"]);
  conn.Close();
  MessageBox.Show("修改成功!","信息",MessageBoxButtons.OK,MessageBoxIcon.Information);
  }
  catch (Exception ex)
  {
  MessageBox.Show("修改失败!" + "\n" + ex.Message);
  }
  }



可是这样修改的信息都没存到数据库里面去.
!!!!
有人可以帮我看一下吗???

------解决方案--------------------
跟踪一下报什么错?
conn这个怎么没看到有定义啊?