下面两个datatable的结构完全一样
button3_Click要把合并后的ds.Tables["NF_M_ManageGoods"]提交到数据库,请问这段代码怎么写
public DataSet SelectDataBase(string strSQL,string tempTableName)
{
DataSet ds=new DataSet();
try
{
SqlConnection conn = CreatConnection();
sda = new SqlDataAdapter(strSQL,conn);
ds.Clear();
sda.Fill(ds,tempTableName);
}
catch(System.Exception e)
{
MessageBox.Show(e.Message);
}
return ds;
} private void button1_Click(object sender, System.EventArgs e)
{
string strSQL;
strSQL="select * from NF_M_ManageGoods"; ds=link.SelectDataBase(strSQL,"NF_M_ManageGoods");
this.dataGrid1.DataSource = ds.Tables["NF_M_ManageGoods"];
} private void button2_Click(object sender, System.EventArgs e)
{
DataTable t2 = ds.Tables["NF_M_ManageGoods"].Clone();
DataRow dr=t2.NewRow();
dr["ID"] = "05";
dr["Sort"] = "123";
dr["name"] = "货品名称";
dr["spec"] = "个";
dr["unit"] = "双";
dr["Enter_Price"] = 30.4;
dr["Sell_Price"] = 56.8;
dr["Re"] = "备注here";
t2.Rows.Add(dr);
ds.Merge(t2,false,MissingSchemaAction.Add);
this.dataGrid1.DataSource = ds.Tables["NF_M_ManageGoods"]; } private void button3_Click(object sender, System.EventArgs e)
{
}
button3_Click要把合并后的ds.Tables["NF_M_ManageGoods"]提交到数据库,请问这段代码怎么写
public DataSet SelectDataBase(string strSQL,string tempTableName)
{
DataSet ds=new DataSet();
try
{
SqlConnection conn = CreatConnection();
sda = new SqlDataAdapter(strSQL,conn);
ds.Clear();
sda.Fill(ds,tempTableName);
}
catch(System.Exception e)
{
MessageBox.Show(e.Message);
}
return ds;
} private void button1_Click(object sender, System.EventArgs e)
{
string strSQL;
strSQL="select * from NF_M_ManageGoods"; ds=link.SelectDataBase(strSQL,"NF_M_ManageGoods");
this.dataGrid1.DataSource = ds.Tables["NF_M_ManageGoods"];
} private void button2_Click(object sender, System.EventArgs e)
{
DataTable t2 = ds.Tables["NF_M_ManageGoods"].Clone();
DataRow dr=t2.NewRow();
dr["ID"] = "05";
dr["Sort"] = "123";
dr["name"] = "货品名称";
dr["spec"] = "个";
dr["unit"] = "双";
dr["Enter_Price"] = 30.4;
dr["Sell_Price"] = 56.8;
dr["Re"] = "备注here";
t2.Rows.Add(dr);
ds.Merge(t2,false,MissingSchemaAction.Add);
this.dataGrid1.DataSource = ds.Tables["NF_M_ManageGoods"]; } private void button3_Click(object sender, System.EventArgs e)
{
}
解决方案 »
- c# 游戏服务端Npc创建
- 好幾天了,來個高手搬下我吧,算法問題~
- 关于FileStream保存文件的困惑
- 字符串加密问题
- 求助自己做一个timer,怎样赋参数?
- 求读取CPU ID 号的c#代码,c++ 也可以。
- 在C#中,用GetHostAddresses()方法获取到的主机地址有多个,但是有些不是合法的IP,这是怎么回事?
- .net 2.0的一个问题。错误Illegal cross-thread operation
- dataGrid1所显示的内容怎么保存为txt文件或excl文件?
- C#的中文问题,请指点(如解决了我再给他加60分)
- nunit测试时如何判断不等于、大于、小于的结果?
- 动态设定报表数据源,可是水晶报表显示为空,这个问题困扰一天了
DataTable.Merge(DataTable)方法。