T
Taryon
Hi All!
i have an handler to save some informations on the database. works very
fine. well. i change the sql INSERT string to include a new item. Now im
getting an INTERNAL SERVER ERROR - 500. and even i change to old code i
still have the error.
This is the client code.
HttpWebRequest req1 =
(HttpWebRequest)WebRequest.Create(serverUrlTextbox.Text);
req1.Method = "PUT";
req1.AllowWriteStreamBuffering = true;
Stream reqS = req1.GetRequestStream();
StreamWriter wrtr1 = new StreamWriter(reqS);
wrtr1.WriteLine("AGENT=5555");
wrtr1.WriteLine(DateTime.Now.ToShortDateString());
wrtr1.WriteLine(DateTime.Now.ToShortTimeString());
wrtr1.WriteLine("*");
for (int i = 0; i < 3; i++)
{
wrtr1.WriteLine("information");
}
wrtr1.Close();
// Submit the request and get the response object
HttpWebResponse resp1 = (HttpWebResponse) req1.GetResponse();
// Retrieve the response stream and wrap in a StreamReader
Stream respStream1 = resp1.GetResponseStream();
StreamReader rdr1 = new StreamReader(respStream1);
// Read through the response line-by-line
string inLine1 = rdr1.ReadLine();
rdr1.Close();
}
==================================
This is the Handler code
// Read the incoming data
inLine=codes[1];
//sw.WriteLine("agente");
string sqla="INSERT INTO CHARGES(AGENT, DATAOCORRENCIA, HORAOCORRENCIA)
VALUES (";
string pvez="'";
while (inLine != null)
{
sqla+=pvez+inLine+"'";
inLine = rdr.ReadLine();
pvez=",'";
if (inLine=="*") break;
}
sqla+=")";
//sw.WriteLine(sqla);
OdbcCommand cmd1 = new OdbcCommand(sqla,conn);
cmd1.ExecuteNonQuery();
OdbcCommand cmdx = new OdbcCommand("SELECT @@IDENTITY", conn);
long nId = Convert.ToInt64(cmdx.ExecuteScalar());
inLine = rdr.ReadLine();
string sql3="";
while (inLine != null)
{
sql3="INSERT INTO ALLCUST(CHARGE, ENQUADRAMENTO) VALUES
("+nId.ToString()+",'"+inLine+"')";
OdbcCommand cm = new OdbcCommand(sql3,cnn);
cm.ExecuteNonQuery();
inLine=rdr.ReadLine();
}
wrtr.WriteLine("fim");
wrtr.Flush();
========================
I receive the error in this line of the client code.
// Submit the request and get the response object
HttpWebResponse resp1 = (HttpWebResponse) req1.GetResponse();
PS. this is the code that was working before. The change that i did was a
new line writed in the client code and a new item in the select server code.
i have an handler to save some informations on the database. works very
fine. well. i change the sql INSERT string to include a new item. Now im
getting an INTERNAL SERVER ERROR - 500. and even i change to old code i
still have the error.
This is the client code.
HttpWebRequest req1 =
(HttpWebRequest)WebRequest.Create(serverUrlTextbox.Text);
req1.Method = "PUT";
req1.AllowWriteStreamBuffering = true;
Stream reqS = req1.GetRequestStream();
StreamWriter wrtr1 = new StreamWriter(reqS);
wrtr1.WriteLine("AGENT=5555");
wrtr1.WriteLine(DateTime.Now.ToShortDateString());
wrtr1.WriteLine(DateTime.Now.ToShortTimeString());
wrtr1.WriteLine("*");
for (int i = 0; i < 3; i++)
{
wrtr1.WriteLine("information");
}
wrtr1.Close();
// Submit the request and get the response object
HttpWebResponse resp1 = (HttpWebResponse) req1.GetResponse();
// Retrieve the response stream and wrap in a StreamReader
Stream respStream1 = resp1.GetResponseStream();
StreamReader rdr1 = new StreamReader(respStream1);
// Read through the response line-by-line
string inLine1 = rdr1.ReadLine();
rdr1.Close();
}
==================================
This is the Handler code
// Read the incoming data
inLine=codes[1];
//sw.WriteLine("agente");
string sqla="INSERT INTO CHARGES(AGENT, DATAOCORRENCIA, HORAOCORRENCIA)
VALUES (";
string pvez="'";
while (inLine != null)
{
sqla+=pvez+inLine+"'";
inLine = rdr.ReadLine();
pvez=",'";
if (inLine=="*") break;
}
sqla+=")";
//sw.WriteLine(sqla);
OdbcCommand cmd1 = new OdbcCommand(sqla,conn);
cmd1.ExecuteNonQuery();
OdbcCommand cmdx = new OdbcCommand("SELECT @@IDENTITY", conn);
long nId = Convert.ToInt64(cmdx.ExecuteScalar());
inLine = rdr.ReadLine();
string sql3="";
while (inLine != null)
{
sql3="INSERT INTO ALLCUST(CHARGE, ENQUADRAMENTO) VALUES
("+nId.ToString()+",'"+inLine+"')";
OdbcCommand cm = new OdbcCommand(sql3,cnn);
cm.ExecuteNonQuery();
inLine=rdr.ReadLine();
}
wrtr.WriteLine("fim");
wrtr.Flush();
========================
I receive the error in this line of the client code.
// Submit the request and get the response object
HttpWebResponse resp1 = (HttpWebResponse) req1.GetResponse();
PS. this is the code that was working before. The change that i did was a
new line writed in the client code and a new item in the select server code.