怎么用dataset将新的记录添加到数据库
代码如下图protected void Button1_Click(object sender, EventArgs e)
{ DataSet1 ds = new DataSet1();
DataSet1.STAFFRow newrow = ds.STAFF.NewSTAFFRow();
newrow.BeginEdit();
int staffid=88;
newrow.CLERKID = staffid;
newrow.NAME = this.TextBox1.Text.ToString();
newrow.SEX = this.DropDownList1.Text.ToString();
newrow.MERRY = this.TextBox2.Text.ToString();
newrow.DEPT = this.DropDownList2.Text.ToString();
newrow.DUTY = this.TextBox3.Text.ToString();
newrow.SALARY = Decimal.Parse(this.TextBox4.Text.ToString());
newrow.TEL = this.TextBox5.Text.ToString();
newrow.ADDRESS = this.TextBox6.ToString();
newrow.EndEdit();
ds.STAFF.AddSTAFFRow(newrow);
if (BLLhelp.add2(ds) > 0) ;
Response.Write("<script>alert('插入成功')</script>");
}
public DataSet add2(DataSet ds)
{
string str8 = "p_staff_i";
DALhelp d = new DALhelp();
return Int32.Parse(d.exce2(str8, ds));}
public string exce2(string str, DataSet ds)
{
SqlConnection conn = DALhelp.con();
conn.Open();
SqlCommand com = new SqlCommand(str, conn);
com.CommandType = CommandType.StoredProcedure;
SqlDataAdapter da = new SqlDataAdapter();
da.Fill(ds);
da.Update(ds);
} dataset 数据库
补充:.NET技术 , ASP.NET