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

Amit GuptaRank #190 · 12.8K reputationPosted Dec 13, 2017, 11:49 AM EST
Nakul ChaudhariRank #914 · 2.3K reputationPosted Dec 13, 2017, 8:09 AM EST
Dharmraj ThakurRank #577 · 4.2K reputationPosted Dec 13, 2017, 6:57 PM EST
darma tejaRank #3,199 · 449 reputationPosted Dec 13, 2017, 11:07 PM EST
Amit GuptaRank #190 · 12.8K reputationPosted Dec 14, 2017, 2:52 AM EST