数据库query.mdb 表:query 列: title
如何实现像类似百度一样的站内查询
如:
输入ABCD
如何得到A,AB,BC,CD,ABC,BCD,ABCD
sql语句怎么写?
能给个算法..或者是代码
[此贴子已经被作者于2007-6-25 16:37:53编辑过]
public void sq_click(Object sender , EventArgs e)
{
string QurStr =this.TextBox1.Text.Trim();
string Ss = "";
int intLen =QurStr.Length();
for (int i = 0; i < intLen; i++)
{
Ss += QurStr[i].ToString + "%";
}
string sql = "select * from tablename where title like '%" + Ss + "'";
OleDbConnection cnn = new OleDbConnection("provider=Microsoft.Jet.OLEDB.4.0;Data Source=" & Server.MapPath("./database/query.mdb"));
OleDbDataAdapter cmd = new OleDbDataAdapter(sql, cnn);
DataSet dt = new DataSet();
cmd.fill(dt);
repeater1.Datasource = dt;
repeater1.dataBind();
cnn.close();
编译器错误信息: CS0118: “string.Length”是“属性”,但此处被当做“方法”来使用
源错误:
行 12: string QurStr =this.TextBox1.Text.Trim();
行 13: string Ss = "";
行 14: int intLen = QurStr.Length();
行 15: for (int i = 0; i < intLen; i++)
行 16: {
[此贴子已经被作者于2007-6-28 17:04:12编辑过]