i am doing a continuously select every 10seconds, so i thought i would do some premature optimsing and save creating a cmd and paramater objects in everyloop
if i do this in one method
public void FirstSelect() {
// select data
this.cmdSelectData = new SqlCommand(SQL_SELECT_DATA, conn);
this.paramBranchId = new SqlParameter("@branch_id", 1);
this.cmdSelectData.Parameters.Add(paramBranchId);
// fetch data blah, blah, blah...
}
and then this in another method
public void SecondSelect() {
this.paramBranchId.Value = 2;
// fetch data
}
would that work as expected, one select using branch 1, one select using branch 2 or do i need to
this.cmdSelectData.Parameters.Clear();
ths.cmdSelectData.Parameters.Add(new SqlParameter( // for branch 2)
}