问题相关搜索 [英] question realated searching
本文介绍了问题相关搜索的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!
问题描述
我在网站上使用文本框从所有其他网站的数据库中搜索目的
我该怎么办
i am using textbox in website for searching purpose from database like all other website
how can i do it
推荐答案
尝试:
using (SqlConnection con = new SqlConnection(strConnect))
{
con.Open();
using (SqlCommand cmd = new SqlCommand("SELECT iD, description FROM myTable WHERE searchColumn LIKE '%' + @SV + '%'", con))
{
cmd.Parameters.AddWithValue("@SV", mySearchTextBox.Text);
using (SqlDataReader reader = cmd.ExecuteReader())
{
while (reader.Read())
{
int id = (int) reader["iD"];
string desc = (string) reader["description"];
Console.WriteLine("ID: {0}\n {1}", iD, desc);
}
}
}
}
这篇关于问题相关搜索的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!
查看全文