• λ我爱Aspx >> Asp.Net >> 关于 Sql 多条件查询传参数的问题
  • 关于 Sql 多条件查询传参数的问题

  • :aspxer  Դ:csdn  :2007-7-6 2:51:20  ؼ:sql
  • 我要从三个文本框中获得参数,但这三个文本框也许只填了一个,两个,我该用怎么样的 Sql 语句?比如查询图书可以用 图书名,作者,类别,我要怎么样查啊?

    google_ad_width = 250; google_ad_height = 250; google_ad_format = "250x250_as"; google_color_url = "000000";

    第2楼. 由 imwjb 于 2007-7-1 23:49:30 发表

    string num=textbox1.text;

    string desc=textbox2.text;

    string fl=textbox3.text;

    string sql = "select custid,customer,fl,typ"

    +" from top_cust where typ=""+typ+""";

    if (num.Length > 0) sql = sql + " and custid like "" + num.Replace(""", "’") + "%"";

    if (desc.Length > 0) sql = sql + " and customer like "%" + desc.Replace(""", "’") + "%"";

    if (fl.Length > 0) sql = sql + " and fl= "" + fl.Replace(""", "’") + """;

    sql = sql + " order by fl,custid";

    ..╭╮__╭╭╭╭__╭╮

    │ │ ╭———————————---—- ╮

    │ ^ ^ │ │★?~”Ccc¨ 〃~≠★ │

    │≡ ≡│ ╭╮│

    │ 3 │O╰╯╰————————————---- ╯

    Ҷƪл˵?
  • һƪ在 System.InvalidOperationException 中第一次偶然出现的“System.Data.dll”类型的异常
    һƪ格式化字符串的问题。