SqlDataAdapter adapter = null;
DataSet ds = null; private void Form3_Load(object sender, System.EventArgs e)
{
string ConStr = ("server=(local);uid=sa;pwd=pass;database=pubs");
SqlConnection Conn = new SqlConnection(ConStr);
Conn.Open();
string sql = "select name, tel from addrbook ";
adapter = new SqlDataAdapter();
adapter.SelectCommand = new SqlCommand( sql, Conn );
ds = new DataSet();
adapter.Fill( ds, "emp" );
dataGrid1.DataSource = ds;
dataGrid1.DataMember = "emp";
Conn.Close();
}
private void button1_Click(object sender, System.EventArgs e)
{
SqlCommandBuilder sCb = new SqlCommandBuilder(adapter);
adapter.Update(ds, "emp");
MessageBox.Show("저장완료");
}
댓글 없음:
댓글 쓰기