what's wrong in where condition statement
SqlConnection con =
new SqlConnection
(@"Data Source=SAMA-PC\SQLEXPRESS;Initial Catalog=advCenter;
Integrated Security=True");
SqlCommand com1 = new SqlCommand(
"select visited_link
from links
where [user_email]=@ue and [visited_link]=@vl",con);
com1.Parameters.AddWithValue("@ue",Convert.ToString(Session["mail"]));
com1.Parameters.AddWithValue("@vl", ImageButton1.ID);
con.Open();
SqlDataReader dr开发者_Go百科;
dr = com1.ExecuteReader();
if (dr.HasRows)
{
Label2.Text = "wrong";
}
Use the following:
"... and CAST([visited_link] AS NVARCHAR(MAX))=@vl "
Refer to the following
CAST and CONVERT (Transact-SQL)
HOW TO: Compare Values in NTEXT Field
I guess you can try
command.Parameters.Add("@ue", SqlDbType.NText)
command.Parameters("@ue").Value = Convert.ToString(Session["mail"]);
to explicitly specify the column data type.
精彩评论