I'm doing an Ozeki Messenger Project using C#. I want to retrieve more than one record from the table. Its returning me the first record only...
Here's my code. Any Idea what am doing wrong guys?
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)
{
}
}
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");
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) { } }
I got The Answer Myself.. LOL. The Response.Redirect should be outside the While Loop. It Works Just fine :D