110,538
社区成员
发帖
与我相关
我的任务
分享
BindingSource bs = new BindingSource();
SqlConnection cn = new SqlConnection("[连接串]");
SqlCommand cm = new SqlCommand("pro_loaddata", cn);
cm.CommandType = CommandType.StoredProcedure;
SqlDataAdapter da = new SqlDataAdapter(cm);
DataSet ds = new DataSet();
da.Fill(ds);
if (ds != null && ds.Tables.Count > 0)
{
DataTable dt;
dt = ds.Tables[0];
bs.DataSource = dt;
dg.DataSource = bs;
}
SqlConnection cn = new SqlConnection("[连接串]");
SqlCommand cm = new SqlCommand("pro_loaddata", cn);
dg.EndEdit();
bs.EndEdit();
Adapter.SelectCommand = new SqlCommand(sql, cn);
SqlCommandBuilder builder = new SqlCommandBuilder(Adapter);
Adapter.UpdateCommand = builder.GetUpdateCommand();
DataView tab = bs.List as DataView;
DataTable table = tab.Table;
Adapter.Update(table);