darma teja

darma teja

  • NA
  • 496
  • 336.7k

where to write sqlparameters before/after CommandText

Dec 13 2017 10:46 AM
where to write sqlparameters before/after sqlCommand CommandText
 
Which one is right?
 
Process1:
 
int id=2;
SqlCommand cmd= new SqlCommand();
cmd.CommandText= "select * from Customer where id= @id";
cmd.Parameters.Add(new SqlParameter("@id", id));
 
Process2:
 
int id=2;
SqlCommand cmd= new SqlCommand();
cmd.Parameters.Add(new SqlParameter("@id", id));
cmd.CommandText= "select * from Customer where id= @id";

Answers (5)