例子:我在method类里面写了个all方法,如下:
public DataTable all()
{
SqlConnection lg = new SqlConnection(address);
SqlCommand s = new SqlCommand("ProgoodsInfo",lg);
s.CommandType = CommandType.StoredProcedure;
lg.Open();
s.ExecuteReader();
lg.Close();
da = new SqlDataAdapter(s);
da.Fill(table);
return table;
}
该方法返回的是datatable型的数据,然后我要在dataGridView获取该table,在dataGridView里显示查出来的数据,然后我要改数据,然后我想单击“更新”按钮,数据就改过来了,然后更新回数据库,这个 SqlCommandBuilder 该怎么写?
public DataTable all()
{
SqlConnection lg = new SqlConnection(address);
SqlCommand s = new SqlCommand("ProgoodsInfo",lg);
s.CommandType = CommandType.StoredProcedure;
lg.Open();
s.ExecuteReader();
lg.Close();
da = new SqlDataAdapter(s);
da.Fill(table);
return table;
}
该方法返回的是datatable型的数据,然后我要在dataGridView获取该table,在dataGridView里显示查出来的数据,然后我要改数据,然后我想单击“更新”按钮,数据就改过来了,然后更新回数据库,这个 SqlCommandBuilder 该怎么写?
解决方案 »
- 分组选择复选框
- 用.NET做网站,头文件 是不是用 用户控件给做成公共文件?
- http://localhost/可以打开主页,而http://localhost/Default.aspx却显示404错误。 Why???
- Gridview显示数据,多加一列显示行号,但要求如果某列的上下两行的值相等,则不显示行号,怎么实现啊
- 水晶报表加载失败??????????????
- .net 菜鸟提问.
- dropdownlist 的一个问题
- 我现在研究网上如何付款的技术,使用什么产品(或技术)比较合适面对全球?
- 用户控件的问题???
- 一个关于vs2003的编辑的问题
- 提个问题,关于开心网等诸如此类社交网站
- 大家帮帮忙啊
public DataTable all()
{
SqlConnection lg = new SqlConnection(address);
lg.Open();
SqlCommand s = new SqlCommand("ProgoodsInfo",lg);
s.CommandType = CommandType.StoredProcedure;
s.ExecuteReader();
da = new SqlDataAdapter(s,lg);
SqlCommandBuilder scb = new SqlCommandBuilder(da);
da.Fill(table,"Stu");
//修改数据
DataRow[] drs = table.Select("学号='05205020228'");
drs[0]["年龄"] = 25;
da.Update(table,"Stu");
return table;
}