我想使用带有字符串值的类似查询。我是这样写的,'_' 用于接受字符串中的字符。但它不起作用。查询字符串是否正确?请帮忙 。
userName = nvc["user_name"];
string userName_Remove_First = userName.Substring(1); //Removes the first character of userName
string Last = userName_Remove_First.Remove(userName_Remove_First.Length - 1); //Removes the last character of userName_Remove_First
SqlCommand cmd = new SqlCommand("select student_id,student_name from student_details where student_id LIKE ('"+last+"_') ", con);
SqlDataReader dr = cmd.ExecuteReader();