请高手看看我下面的代码(有几处疑问,已标出):
1.本人如下这般写了代码,成功增加,但无法删除已知数据,为什么呢?
2.好象不用打开conn也可以更新,是这样吗
3.为什么这样使用事务不成功 private void Button1_Click(object sender, System.EventArgs e)
{
try
{
DataSet yy=new DataSet();
yy=(DataSet)Session["xx"];
//yy=(DataSet)DataGrid1.DataSource;

SqlCommandBuilder custCB = new SqlCommandBuilder(da);

DataRow rr=yy.Tables["authors"].NewRow();
rr["au_id"]="899-46-2030";
rr["au_lname"]="jhon";
rr["au_fname"]="kkkk";
rr["phone"]="88888";
rr["address"]="kkk";
rr["city"]="jjj";
rr["state"]="ca";
rr["zip"]="95688";
rr["contract"]=0;
yy.Tables["authors"].Rows.Add(rr);//成功
DataRow r1;

DataColumn[] myColArray = new DataColumn[1];
myColArray[0] = yy.Tables["authors"].Columns["au_id"];
yy.Tables["authors"].PrimaryKey = myColArray; r1=yy.Tables["authors"].Rows.Find("899-46-2033");
yy.Tables["authors"].Rows.Remove(r1);//不成功???????
if(r1==null)
{
Response.Write("no found");
} da.Update(yy,"authors");
//SqlTransaction tr;
//conn.Open();//不用也可以?????
//tr=conn.BeginTransaction();
DataGrid1.DataSource=yy.Tables["authors"].DefaultView;

//tr.Rollback();//不管用,仍可加入数据??????
//conn.Close();
DataGrid1.DataBind();
}
catch(Exception ex)
{
Response.Write(ex.Message);
}
}