using System;
using System.Collections.Generic;
using System.ComponentModel;
using System.Data;
using System.Drawing;
using System.Linq;
using System.Text;
using System.Windows.Forms;
using System.Configuration;
using System.Data.SqlClient;
namespace 数据同步
{
public partial class Form1 : Form
{
public Form1()
{
InitializeComponent();
}
DataTable dt = null;
SqlDataAdapter sa = null;
BindingSource bs = null;
SqlConnection con = null;
SqlCommandBuilder sb = null;
private void Form1_Load(object sender, EventArgs e)
{
con = new SqlConnection("data source=WIN-07Q4IAKLGNF\\SQLEXPRESS;database=kefu;integrated security=true");
try
{
con.Open();
sa = new SqlDataAdapter("select * from T_Manager", con);
sb = new SqlCommandBuilder(sa);
dt = new DataTable();
sa.Fill(dt);
dataGridView1.DataSource = dt;
bs = new BindingSource();
bs.DataSource = dt;
con.Close();
}
catch (Exception ex)
{
con.Close();
throw ex;
}
}
private void button1_Click(object sender, EventArgs e)
{
sa.Update((DataTable)bs.DataSource);
}
}
}