Exemple #1
0
        public void UpdateTable(DataSet db, string tableName, reviseClass reviseData)
        {
            sql = "select * from " + tableName;
            DataTable dt = null;

            try
            {
                SqlDataAdapter sda = new SqlDataAdapter();
                sda.SelectCommand = new SqlCommand(sql, sqlConnection);
                SqlCommandBuilder cb = new SqlCommandBuilder(sda);//自动生成相应的命令,这句很重要

                sda.Fill(db);
                dt = db.Tables[0];
                DataRow dr = dt.NewRow();

                //for (int i = 0; i < reviseData.getHashtable().Count; i++)
                //{
                //    dr[reviseData.getKeys()[i]] = reviseData.getValues()[i];
                //    dt.Rows.Add(dr);
                //}

                dr["均深"] = 9999.0f;
                dt.Rows.Add(dr);

                sda.Update(dt); //对表的更新提交到数据库
                                //DataRow[] drs = dt.Select(null, null, DataViewRowState.Added);//或者搜索之后再更新
                                //sda.Update(drs);

                dt.AcceptChanges();
            }
            catch (SqlException ex)
            { }
            finally
            {
                sqlConnection.Close();
            }
        }
Exemple #2
0
        static void Main(string[] args)
        {
            string          path  = "C:\\Users\\Administrator\\Desktop\\logData.xls";
            adoLoadExcel_ZB loadA = new adoLoadExcel_ZB(path);

            loadA.closeDB();
            Console.WriteLine("point1");

            String[] inputData = new string[4];

            reviseClass reviseData = new reviseClass(loadA.conExcel(), inputData);

            reviseDB_ZB reviseA = new reviseDB_ZB();

            reviseA.UpdateTable(loadA.conExcel(), "Sheet1$", reviseData);

            Console.WriteLine("point2");


            SVM_ZB x = new SVM_ZB();

            x.linnerSVM(loadA.conExcel());
            Console.WriteLine("point3");
        }