Must declare the scalar variable “@Email”

后端 未结 4 1228
名媛妹妹
名媛妹妹 2020-12-22 00:14

I am trying to pass values from a database table to a couple of labels where the email column matches the email entered.I have passed the email entered from login page to th

4条回答
  •  情书的邮戳
    2020-12-22 00:28

    @Email indicates a variable, not a field name. If the field name in your table is @Email enclose it in square brackets... [@Email] but I would guess that the field name is Email.

    Edit:

    You also have an issue with the where statement, if you are sending text you need to enclose that in quotes:

    SqlCommand cmd = new SqlCommand("Select * from tblRegister where Email = '" + lblEmail.Text + "'", con);
    

    This type of query, simply passing a value entered by the user will open you up to SQL injection.

    More information

提交回复
热议问题