【问题标题】:Ozeki is not returning other records大关不归还其他记录
【发布时间】:2015-04-22 19:03:14
【问题描述】:

我正在使用 C# 做一个 Ozeki Messenger 项目。我想从表中检索多条记录。它只返回了我的第一条记录......

这是我的代码。任何想法做错了什么?

protected void Page_Load(object sender, EventArgs e)
{
    try
    {
        String x;
        String y;
        String z;
        String SenderNumber, receiverNumber, message;
        SenderNumber = Request.QueryString.Get("sender");
        receiverNumber = Request.QueryString.Get("receiver");
        message = Request.QueryString.Get("msg");

        SqlConnection connection = new SqlConnection();
        SqlCommand command = new SqlCommand();
        SqlDataReader reader;

        connection.ConnectionString = Constring;
        command.Connection = connection;

        command.CommandText = "SELECT P_Name, P_Parking FROM tblPharmacy Where Code = '" + message + "'" ;

        connection.Open();

        reader = command.ExecuteReader();            
        String data = "";
        while (reader.Read())
        {
            x = reader["P_Name"].ToString();
            y = reader["P_Parking"].ToString();
            data += x + "  " + y + " - ";

            Response.Redirect("http://localhost:9333/ozeki?login=admin&password=xxxxxx&action=sendMessage&messagetype=SMS:TEXT&recepient=" + SenderNumber + " &messageData= " + data);
        }

        reader.Close();
        connection.Close();
    }
    catch (Exception)
    {
    }
}

【问题讨论】:

  • SELECT P_Name, P_Parking FROM tblPharmacy Where Code = '" + message + "' 将只返回那些代码匹配传递消息的记录。如果您对所述代码有更多记录,请检查数据库
  • 是的,我有...如果我在 ozeki 中键入“all”。它只给了我 Ozeki 标准杆。而不是其他人。 1 Hash Goodlands 2593326 是 8 10 PP 2 Ozeki 某处 3692632 Par 9 10 全部 4 没有其他地方 5236982 Par 8 10 全部 5 Disturled whereelse 4569326 Park 9 10 all 6 不安 hmmmmm 5966532 park 9 10 ON 7 Adeelah goodlands 5263963 park 8 NULL NULL NULL NULL NULL NULL

标签: c# ozeki


【解决方案1】:

protected void Page_Load(object sender, EventArgs e) { 尝试 { 字符串 x; 字符串 y; 字符串 z; 字符串发送者编号、接收者编号、消息; SenderNumber = Request.QueryString.Get("sender"); receiverNumber = Request.QueryString.Get("receiver"); message = Request.QueryString.Get("msg");

    SqlConnection connection = new SqlConnection();
    SqlCommand command = new SqlCommand();
    SqlDataReader reader;

    connection.ConnectionString = Constring;
    command.Connection = connection;

    command.CommandText = "SELECT P_Name, P_Parking FROM tblPharmacy Where Code = '" + message + "'" ;

    connection.Open();

    reader = command.ExecuteReader();            
    String data = "";
    while (reader.Read())
    {
        x = reader["P_Name"].ToString();
        y = reader["P_Parking"].ToString();
        data += x + "  " + y + " - ";

    }

Response.Redirect("http://localhost:9333/ozeki?login=admin&password=xxxxxx&action=sendMessage&messagetype=SMS:TEXT&recepient=" + SenderNumber + " &messageData= " + data); reader.Close(); 连接。关闭(); } 捕捉(例外) { } }

我自己得到了答案。哈哈。 Response.Redirect 应该在 While 循环之外。它工作得很好:D

【讨论】:

    猜你喜欢
    • 2015-06-01
    • 2010-12-05
    • 1970-01-01
    • 1970-01-01
    • 2019-07-09
    • 2016-03-10
    • 1970-01-01
    • 2015-06-18
    • 1970-01-01
    相关资源
    最近更新 更多