且构网

分享程序员开发的那些事...
且构网 - 分享程序员编程开发的那些事

在c#中将数据行添加到数据表中

更新时间:2023-12-06 15:05:46





查看下面的链接...





使用DataSet-and-DataAdapter插入关系数据

[ ^ ]



问候,

RK
Hi,

Check the Link below...


Inserting-relational-data-using-DataSet-and-DataAdapter
[^]

Regards,
RK


大家好/>
运行此代码



SqlDataAdapter da = new SqlDataAdapter(select * from item,con);

con 。打开();

试试

{

DataSet ds = new DataSet();

da.Fill (ds);

SqlCommandBuilder cb = new SqlCommandBuilder(da);









DataRow row1 = ds.Tables [0] .NewRow();



row1 [0] = txtaccno.Text;

row1 [1] = txtname.Text;

row1 [2] = txtsalary.Text;

ds.Tables [0] .Rows.Add(row1);

da.Update(ds);

gvShow.DataSource = ds;

gvShow.DataBind();



问候,

Pawan
Hi All
Run this code

SqlDataAdapter da = new SqlDataAdapter("select * from item ", con);
con.Open();
try
{
DataSet ds = new DataSet();
da.Fill(ds);
SqlCommandBuilder cb = new SqlCommandBuilder(da);




DataRow row1 = ds.Tables[0].NewRow();

row1[0] = txtaccno.Text;
row1[1] = txtname.Text;
row1[2] = txtsalary.Text;
ds.Tables[0].Rows.Add(row1);
da.Update(ds);
gvShow.DataSource = ds;
gvShow.DataBind();

Regards,
Pawan