将本地服务器数据更新到服务器

来源:互联网 发布:淘宝无线端详情页尺寸 编辑:程序博客网 时间:2024/05/22 17:46

使用sqlbulkcopy类将本地未更新到服务器的数据更新到服务器

connServer.Open();            SqlCommand myCommandRole = new SqlCommand("SELECT * FROM Role where 此处为判断是否是新数据", connServer);            SqlDataReader drRole = myCommandRole.ExecuteReader();            connBench.Open();            SqlBulkCopy bulk = new SqlBulkCopy(connBench);            bulk.DestinationTableName = "[Role]";            try            {                bulk.WriteToServer(drRole);                MessageBox.Show("角色更新成功");            }            catch (Exception ex)            {                MessageBox.Show(ex.ToString());            }            finally            {                connBench.Close();                drRole.Close();                connServer.Close();                bulk.Close();            }




原创粉丝点击