Add row using dataadapter.update
Why i am getting an error here,plz help me! adp.Update(ds);
con=new SqlConnection("");
adp=new SqlDataAdapter ("Select * from authors",con);
ds=new DataSet();
MessageBox.Show(con.State.ToString());
adp.Fill(ds,"authors");
MessageBox.Show(ds.Tables[0].Rows.Count.ToString());
dt=ds.Tables["authors"];
}
private void cmdAdd_Click(object sender, System.EventArgs e)
{
adding = true;
txtAuthorID.Focus();
}
private void cmdSave_Click(object sender, System.EventArgs e)
{
con.Open();
if (adding==true)
{
workRow = dt.NewRow();
//GetValues();
workRow[0] =11;
workRow[1] ="jelfy";
dt.Rows.Add(workRow);
MessageBox.Show("Added");
adding=false;
adp.Update(ds); dt.AcceptChanges();
}
else
{
//GetValues();
}
//adp.Update(ds,"authors");
con.Close();
}
Thanks
Jelfy
__________________
Thanks
Jelfy
|