110,536
社区成员
发帖
与我相关
我的任务
分享
string strTemp = guanjianzi.Text.Trim().Replace("'","''");
string strSql = string.Format(@"SELECT * FROM Student WHERE (stuName LIKE '%{0}%' OR
stuSex LIKE '%{0}%' OR stuID LIKE '%{0}%' OR
stuDepart LIKE '%{0}%' * OR zhuanye LIKE '%{0}%'
OR stuClass LIKE '%{0}%' or address LIKE '%{0}%')", strTemp);
//,你缺少单引号,我们假设用户输入了值,你需要判断.另外给你提高了一点效率..
//Replace必须的.
string strTemp = guanjianzi.Text.Trim().Replace("'","''");
SELECT * FROM Student WHERE (stuName LIKE '%strTemp%' OR
stuSex LIKE '%strTemp%' OR stuID LIKE '%strTemp%' OR
stuDepart LIKE '%strTemp%' * OR zhuanye LIKE '%strTemp%'
OR stuClass LIKE '%strTemp%' or address LIKE '%strTemp%')