HttpWebRequest/Response problem - HELP

From: Taryon (taryon_at_fluxwire.com)
Date: 02/29/04


Date: Sun, 29 Feb 2004 09:32:00 -0300

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.



Relevant Pages

  • Re: Question about design, defmacro, macrolet, and &environment
    ... "Expects to find the literal string on the stream." ... (defun send (string &optional stream) ... (declaim (inline make-adjustable-string)) ...
    (comp.lang.lisp)
  • Re: HttpWebRequest/Response problem - HELP
    ... i change the sql INSERT string to include a new item. ... > // Submit the request and get the response object ... > // Retrieve the response stream and wrap in a StreamReader ... > inLine = rdr.ReadLine; ...
    (microsoft.public.dotnet.languages.csharp)
  • Webrick streaming bodies
    ... The longer the string assigned to response.body, ... Ideally, the handler would prep the HTTP headers, then would pass a stream ... stream would push them out the raw TCP/IP ports synchronously. ...
    (comp.lang.ruby)
  • [PATCH 1/2] cifs: little cleanups for cifs_unicode.h - functions and comments
    ... Concatenate the second string to the first ... -static inline wchar_t * ... +/* UniStrcat: Concatenate the second string to the first ... +static inline int UniStrcmp ...
    (Linux-Kernel)
  • Re: Strange problem when not in debugger
    ... private string huidigWeb; ... int buffLength = 2048; ... // Opens a file stream to read the file to be uploaded ...
    (microsoft.public.dotnet.languages.csharp)

Loading