Chinaunix首页 | 论坛 | 博客
  • 博客访问: 4133171
  • 博文数量: 70
  • 博客积分: 5010
  • 博客等级: 大校
  • 技术积分: 1400
  • 用 户 组: 普通用户
  • 注册时间: 2007-09-27 15:06
文章存档

2011年(2)

2010年(23)

2009年(21)

2008年(24)

我的朋友

分类:

2009-06-18 09:47:17

  if (this.textBox2.Text.Trim() == "")
            {
                MessageBox.Show("请输入EXCEL文件路径!");
            }
            else
            {
                string fileName = "告警手册-中兴.xls";
                string currPath = this.textBox2.Text.Trim();
                if (!currPath.Substring(currPath.Length - 1).Contains("\\"))
                {
                    currPath = currPath + "\\";
                }
                fileName = currPath + fileName;
}
 try
            {
                string strSheetName = "中兴-RNC";
                string strConn = "Provider=Microsoft.Jet.OLEDB.4.0;Data Source=" + path + ";Extended Properties='Excel 8.0;HDR=Yes;IMEX=1;'";
                string strExcel = "select * from  [" + strSheetName + "$] ";
                DataSet ds = new DataSet();
                OleDbConnection conn = new OleDbConnection(strConn);
                conn.Open();
                OleDbDataAdapter adapter = new OleDbDataAdapter(strExcel, conn);
                adapter.Fill(ds, "data");
                conn.Close();
                DataTable excelDT = ds.Tables["data"];//EXCEL表
                OracleConnection ocon = new System.Data.OracleClient.OracleConnection("data source=cqwcdma;user id=ifms_test;pwd=ifms;");
                foreach (DataRow dr in excelDT.Rows)
                {
                    string alarmCode = dr["告警码"].ToString();
                    string experience = dr["处理建议"].ToString();
                    ocon.Open();
                    OracleCommand ocmd = new OracleCommand("select count(*) from alarmcause t where vendor='ZY0804' and (experience is null or dbms_lob.compare(experience, empty_clob()) = 0) and alarmcause like '%" + alarmCode + "%' or  probablecause like '%" + alarmCode + "%'", ocon);
                    int count = int.Parse(ocmd.ExecuteScalar().ToString());
                    ocon.Close();
                    if (count > 0)
                    {
                        ocon.Open();
                        ocmd = new OracleCommand("update alarmcause t set experience='" + experience + "' where vendor='ZY0804' and alarmcause like '%" + alarmCode + "%' or  probablecause like '%" + alarmCode + "%'", ocon);
                        ocmd.ExecuteNonQuery();
                        ocon.Close();
                    }
                }
                MessageBox.Show("操作成功!", "提示", MessageBoxButtons.OK, MessageBoxIcon.Information);
            }
            catch (Exception se)
            {
                MessageBox.Show("操作失败:"+se.Message);
            }
阅读(3632) | 评论(0) | 转发(0) |
给主人留下些什么吧!~~