Dear experts,
I would like to know what are @fn,@tel, @eml are ?
Are these names we just anyhow gave ? If not where on earth it came from ?
- protected void btnCreate_Click(object sender, EventArgs e)
- {
- DAO.MembersDAO memDAO = new DAO.MembersDAO();
- string sql = "INSERT INTO member VALUES (@fn, @tel, @eml)";
- //SqlParameterCollection spc = null;
- //spc.Add(new SqlParameter("@fn", SqlDbType.NVarChar)).Value = txtFullName.Text;
- //spc.Add(new SqlParameter("@tel", SqlDbType.NVarChar)).Value = txtTel.Text;
- //spc.Add(new SqlParameter("@eml", SqlDbType.NVarChar)).Value = txtEmail.Text;
- SqlParameter[] spa = new SqlParameter[3];
- spa[0] = new SqlParameter("@fn", SqlDbType.NVarChar);
- spa[0].Value = txtFullName.Text;
- spa[1] = new SqlParameter("@tel", SqlDbType.NVarChar);
- spa[1].Value = txtTel.Text;
- spa[2] = new SqlParameter("@eml", SqlDbType.NVarChar);
- spa[2].Value = txtEmail.Text;
- int result = memDAO.InsertMember(sql, spa);
- if (result == 1)
- {
- Response.Redirect("MemberList.aspx");
- }

Ranjit PowarRank #553 · 4.4K reputationPosted Oct 31, 2016, 7:44 PM EDT
Prakash KumarRank #1,798 · 828 reputationPosted Oct 31, 2016, 8:13 PM EDT
Salman BegRank #284 · 8.8K reputationPosted Oct 31, 2016, 5:16 AM EDT
Pradeep SahooRank #489 · 5.1K reputationPosted Oct 31, 2016, 5:19 AM EDT
Tangara GRank #4,983 · 316 reputationPosted Oct 31, 2016, 7:59 AM EDT
Manas MohapatraRank #182 · 13.2K reputationPosted Oct 31, 2016, 10:45 AM EDT
@tel - It relates to Telephone number
@eml - It relates to Email
These are SQL parameters names which you are passing to execute SQL query.
It looks you are using inline query, so you should use parameterised to avoid SQL injection.
SQL parameters are used in Inline SQL queries or calling the Stored procedure.
Secongly the parameters names should same as SQL query param names.
Ranjit PowarRank #553 · 4.4K reputationPosted Oct 31, 2016, 7:44 PM EDT
Bikesh SrivastavaRank #108 · 20.3K reputationPosted Nov 1, 2016, 4:31 AM EDT
Tangara GRank #4,983 · 316 reputationPosted Nov 1, 2016, 6:32 AM EDT
Francis SusaimichaelRank #466 · 5.4K reputationPosted Nov 1, 2016, 7:17 AM EDT