You can use this
For reading data we use state table and function is
public void readstate()
{
dataAdState.SelectCommand = new SqlCommand("select * from state_master", con);
dataAdState.InsertCommand = new SqlCommand("insert into state_master(state_id,state_name) values(@state_id,@state_name)", con);
dataAdState.InsertCommand.Parameters.Add("@state_name", SqlDbType.Text).SourceColumn="state_name";
dataAdState.InsertCommand.Parameters.Add("@state_id", SqlDbType.Int).SourceColumn = "state_id";
dataAdState.UpdateCommand = new SqlCommand("update state_master set state_name=@state_name where state_id=@state_id",con);
dataAdState.UpdateCommand.Parameters.Add("@state_name", SqlDbType.Text).SourceColumn = "state_name";
dataAdState.UpdateCommand.Parameters.Add("@state_id", SqlDbType.Int).SourceColumn = "state_id";
dataAd.DeleteCommand = new SqlCommand("delete from state_master where state_id=@state_id");
dataAdState.DeleteCommand.Parameters.Add("@state_id", SqlDbType.Int).SourceColumn = "state_id";
dataAdState.Fill(dataset, "State");
dataset.Tables["State"].PrimaryKey = new DataColumn[] { dataset.Tables["State"].Columns["state_id"] };
}
And this for update data.
public void updateState(int state_id, string name)
{
dataset.Tables["State"].PrimaryKey = new DataColumn[] { dataset.Tables["State"].Columns["state_id"] };
DataRow row = dataset.Tables["State"].Rows.Find(state_id);
row["state_name"] = name;
DataTable d = dataset.Tables["State"].GetChanges(DataRowState.Modified);
dataAdState.Update(d);
}
same for delete