请先看下面的代码( DataSet1为一强类型DataSet. )
DataSet1 ds1 = new DataSet1();
SqlConnection conn = new SqlConnection();
conn.ConnectionString = @".....";
conn.Open();
SqlCommand comm = new SqlCommand();
comm.CommandType = CommandType.Text;
comm.CommandText &#61; "select * from article where ariticle_id <0";//这里&#xff01;让选择的结果集为空是可行的&#xff01; 这样可以提高效率。但是这个语句一定要写&#xff0c;还不能写为""&#xff0c;并且要把结果Fill到ds1中。
comm.Connection &#61; conn;
SqlDataAdapter adapter &#61; new SqlDataAdapter();
adapter.SelectCommand &#61; comm;
SqlCommandBuilder builder &#61; new SqlCommandBuilder(adapter);
adapter.Fill(ds1,ds1.Article.TableName);
DataSet1.ArticleRow drNew &#61; ds1.Article.NewArticleRow();
drNew.Ariticle_ID &#61; int.Parse(this.TextBox1.Text);
drNew.User_ID &#61; int.Parse(this.TextBox2.Text);
drNew.Title &#61; this.TextBox3.Text;
drNew.Content &#61; this.TextBox4.Text;
drNew.AddTime &#61; DateTime.Now;
drNew.CheckTime &#61; DateTime.Now;
drNew.ViewCount &#61; int.Parse(this.TextBox5.Text);
ds1.Article.AddArticleRow(drNew);
adapter.Update(ds1,ds1.Article.TableName);//插入或更新.
问题是&#xff1a;
1> 为什么还需要先select一个结果集&#xff0c;然后邦定到ds1&#xff0c;然后操作ds1&#xff0c;更新ds1&#xff1f;
“先select一个结果集”&#xff1a;我们可以故意让结果为0条记录&#xff0c;既然这样&#xff0c;还需要这个作什么用&#xff1f;Ado.Net这样的设计&#xff0c;让人觉得不舒服&#xff01;
2> 有其他通过DataSet刷新数据的“看起来比较正常的”方法吗&#xff1f;