我可以在命令构建器和datagridview中使用存储过程吗?

时间:2016-09-07 18:52:19

标签: c# sql-server stored-procedures datagridview sqlcommandbuilder

SqlConnection con = new SqlConnection("Data source=.;Database=training; 
                                       integrated security =true");
DataSet ds = new DataSet();
SqlDataAdapter da;

private void Form1_Load(object sender, EventArgs e)
{
    cmd = new SqlCommand("select *  from mangers",con);
    da = new SqlDataAdapter(cmd );
    da.Fill(ds, "1");
    dataGridView1.DataSource = ds.Tables[0];
}

private void button1_Click(object sender, EventArgs e)
{
    SqlCommandBuilder cmdb = new SqlCommandBuilder(da);
    da.Update(ds, "1");
}

我想知道我是否可以在DataGridView中插入/删除/更新,然后使用存储过程对数据库进行相同的操作? enter image description here

0 个答案:

没有答案