日期:2014-05-17  浏览次数:20731 次

【SqlDataAdapter.Update()】关于使用DataSet更新
        /// <summary>
        /// 增加DataSet
        /// </summary>
        /// <param name="ds">Oracle DataSet</param>
        /// <param name="tableName">tableName</param>
        public int AddDataSet(DataSet ds1, string tableName)
        {
            string sql = "select * from " + tableName;
            int judge= 0;
            using (SqlConnection connection = new SqlConnection(connectionString))
            {
                SqlDataAdapter da;
                try
                {
                    DataSet ds = new DataSet();
                    connection.Open();
                    da = new SqlDataAdapter(sql, connection);
                    SqlCommandBuilder sb = new SqlCommandBuilder(da);
                    da.InsertCommand = sb.GetInsertCommand();
                    da.Fill(ds, "ds");
                    // 合并Oracle-Sql DataSet
                    ds.Merge(ds1);
                    judge = da.Update(ds,"ds");
                    ds.AcceptChanges();