darma teja

darma teja

  • 1.5k
  • 496
  • 252.9k

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";

Brought to you by: JavaScript SDK for Bold BI dashboard and analytics embedding. Free trial.

Answers (5)