To change an entry of the table is also interesting and easy. You don't need to write an update query or even think of creating and closing a sql connection...even no chance to hurt a primary key also. Just follow these steps. Lets consider the Admin table. Suppose Admin wants to change the password having AdminID=5. So here lies the following code:
try
{
Admin admin=new Admin();
admin.ConnectionString=ConfigurationManager.ConnectionStrings["MASUDDBConnectionString"].
ConnectionString;
if(admin.LoadByPrimaryKey(5))
{
admin.AdminPassword="new password";
admin.Save();
/*entry updated successfully*/
}
}
catch(Exception exc)
{
/*error notification*/
}
So this is the easiest way to update a table entry as I believe. what do you think about this?
thanks
Masud(14.7.9)
No comments:
Post a Comment