如何用DataAdapter往数据库插入新的记录? 在响应Insert按钮事件的过程中放入如下代码:DataRow row=DataSet.Tables[tablename].NewRow();DataSet.Tables[tablename].Rows.Add(row); 解决方案 » 免费领取超大流量手机卡,每月29元包185G流量+100分钟通话, 中国电信官方发货 很简单SqlDataAdapter mya=new SqlDataAdapter("select * from xx where 1=2",conn);SqlCommandBuilder x=new SqlCommandBuilder(mya);mya.fill(ds,"table1");DataRow dr=ds.Tables["table1"].NewRow();dr["name"]=......ds.Tables["table1"].Rows.Add(dr);mya.update(ds,"table1"); select top 0 * from xx好点吧? private void Save_Click(object sender, System.EventArgs e) { myConn.Open(); //myAdapter.Fill(DataSetPI); DataSet ds=new DataSet(); myAdapter.Fill(ds,"Table"); SqlCommandBuilder x=new SqlCommandBuilder(myAdapter); DataRow r=ds.Tables["Table"].NewRow(); r["Datakind"]=tb_kind.Text; r["Dataname"]=tb_name.Text; r["Re"]=tb_rm.Text; r["Resvstr1"]=""; r["Resvint1"]=tb_res.Text; ds.Tables["Table"].Rows.Add(r); myAdapter.Update(ds,"Table"); myConn.Close(); }不行,为什么?错误为:[NullReferenceException: 未将对象引用设置到对象的实例。] 请问Repeater控件怎么用A标签实现删除的效果? location path不起作用 多条件判断 关于网站路径和链接的一些问题 我这样上传图片,为什么不支持.gif图片呢? ASP.net Unicode转换为Native 怎样在.NET作的网页中嵌入.fla文件 各位 小弟着急!!怎么获取前台用脚本得到的listbox里面的所有的值! 在用了CodeBehind的Aspx,Frameset中参数传递?(在线结分) 关于DropDownList控件的问题. 请问刷新当前页面代码怎样写??急急!! 散分了,来着有份,截至1月1日!·#
SqlDataAdapter mya=new SqlDataAdapter("select * from xx where 1=2",conn);
SqlCommandBuilder x=new SqlCommandBuilder(mya);
mya.fill(ds,"table1");
DataRow dr=ds.Tables["table1"].NewRow();
dr["name"]=...
...
ds.Tables["table1"].Rows.Add(dr);
mya.update(ds,"table1");
myConn.Open();
//myAdapter.Fill(DataSetPI);
DataSet ds=new DataSet();
myAdapter.Fill(ds,"Table");
SqlCommandBuilder x=new SqlCommandBuilder(myAdapter);
DataRow r=ds.Tables["Table"].NewRow();
r["Datakind"]=tb_kind.Text;
r["Dataname"]=tb_name.Text;
r["Re"]=tb_rm.Text;
r["Resvstr1"]="";
r["Resvint1"]=tb_res.Text;
ds.Tables["Table"].Rows.Add(r);
myAdapter.Update(ds,"Table");
myConn.Close();
}不行,为什么?错误为:
[NullReferenceException: 未将对象引用设置到对象的实例。]