>>>>对于表中得初始数据,用delet方法,只是对行做上deleted标记,table地行数不变;not true, for example
using System;
using System.Data;
using System.Data.SqlClient;class TestXML
{
public static void Main()
{
SqlConnection conn = new SqlConnection("Server=localhost;Database=pubs;UID=sa;PWD=;");
SqlDataAdapter da = new SqlDataAdapter("select * from authors",conn);
DataSet ds = new DataSet();
da.Fill(ds,"authors");
Console.WriteLine("count:{0}", ds.Tables["authors"].Rows.Count);
ds.Tables["authors"].Rows.RemoveAt(0);
Console.WriteLine("count:{0}", ds.Tables["authors"].Rows.Count); DataRow dr = ds.Tables["authors"].NewRow();
dr["au_id"] = "1234";
ds.Tables["authors"].Rows.Add(dr);
Console.WriteLine("count:{0}", ds.Tables["authors"].Rows.Count);
ds.Tables["authors"].Rows.Remove(dr);
Console.WriteLine("count:{0}", ds.Tables["authors"].Rows.Count);
}
}
using System;
using System.Data;
using System.Data.SqlClient;class TestXML
{
public static void Main()
{
SqlConnection conn = new SqlConnection("Server=localhost;Database=pubs;UID=sa;PWD=;");
SqlDataAdapter da = new SqlDataAdapter("select * from authors",conn);
DataSet ds = new DataSet();
da.Fill(ds,"authors");
Console.WriteLine("count:{0}", ds.Tables["authors"].Rows.Count);
ds.Tables["authors"].Rows.RemoveAt(0);
Console.WriteLine("count:{0}", ds.Tables["authors"].Rows.Count); DataRow dr = ds.Tables["authors"].NewRow();
dr["au_id"] = "1234";
ds.Tables["authors"].Rows.Add(dr);
Console.WriteLine("count:{0}", ds.Tables["authors"].Rows.Count);
ds.Tables["authors"].Rows.Remove(dr);
Console.WriteLine("count:{0}", ds.Tables["authors"].Rows.Count);
}
}
解决方案 »
免费领取超大流量手机卡,每月29元包185G流量+100分钟通话, 中国电信官方发货