How to update Data Table ?

Ranjeet_8
Posted by Ranjeet_8 under ASP.NET category on | Points: 40 | Views : 1032
    SqlConnection Conn=new SqlConnection("Server=Server_Name;Database=DB_Name;UID=Login_ID;PWD=Login_Pwd");
SqlDataAdapter da=new SqlDataAdapter("SELECT uid, uname, fname, cont FROM Emp_Details WHERE uname LIKE 'Xyz%' ORDER BY uname", Conn);
DataTable dt=new DataTable();
DataRow dr;
SqlCommandBuilder cb;

da.Fill(dt);
dr=dt.NewRow();
dr["uid"]="9008";
dr["uname"]="ABC";
dr["fname"]="xyz";
dr["cont"]=1;
dt.Rows.Add(dr);

cb=new SqlCommandBuilder(da);
da.Update(dt);

Comments or Responses

Login to post response