开发者

what's wrong in where condition statement

开发者 https://www.devze.com 2023-03-10 01:01 出处:网络
SqlConnection con = new SqlConnection (@\"Data Source=SAMA-PC\\SQLEXPRESS;Initial Catalog=advCenter; Integrated Security=True\");
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.

0

精彩评论

暂无评论...
验证码 换一张
取 消