qq_33854564 2016-01-26 05:49 采纳率: 50%
浏览 1849
已采纳

求各位大神看一下,运行时查询结果只显示一行

protected void wbtn_find_Click(object sender, EventArgs e)
{
string where = "";
string text = Textname.Text;
for (int i = 0; i < text.Length; i++)
{
string ss = text.Substring(0, 1);
where += "(District_Name LIKE '%" + ss + "%')";
if (i < text.Length - 1)
{
where += " OR ";
}
}
string str = @"SELECT District_Name, District_Code
FROM dbo.D_DISTRICT_MAST
WHERE " + where;
SqlConnection sqlCon = new SqlConnection("data source=.;database=HMMS;uid=sa;pwd=");

    SqlCommand sqlCmd = new SqlCommand(str, sqlCon);

    sqlCon.Open();
    SqlDataReader myReader = sqlCmd.ExecuteReader();

    while (myReader.Read())
    {
        int i = 0;
        TextBox.Text = myReader.GetValue(i).ToString();
        i++;
    }
    myReader.Close();
    sqlCon.Close();
}
  • 写回答

2条回答

  • Go 旅城通票 2016-01-26 05:56
    关注

    TextBox.Text += myReader.GetValue(i).ToString();

    本回答被题主选为最佳回答 , 对您是否有帮助呢?
    评论
查看更多回答(1条)

报告相同问题?

悬赏问题

  • ¥20 有关区间dp的问题求解
  • ¥15 多电路系统共用电源的串扰问题
  • ¥15 slam rangenet++配置
  • ¥15 有没有研究水声通信方面的帮我改俩matlab代码
  • ¥15 对于相关问题的求解与代码
  • ¥15 ubuntu子系统密码忘记
  • ¥15 信号傅里叶变换在matlab上遇到的小问题请求帮助
  • ¥15 保护模式-系统加载-段寄存器
  • ¥15 电脑桌面设定一个区域禁止鼠标操作
  • ¥15 求NPF226060磁芯的详细资料