471,309 Members | 1,023 Online
Bytes | Software Development & Data Engineering Community
Post +

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 471,309 software developers and data experts.

About Error

I am writing program. it get the Source code of site.
for example; site.com/news.asp?id=55 I get the source code. But if I
try the get site.com/news.asp?id=55'a or site.com/news.asp?id=55a it
give me ERROR 500. AND the program NOT GET the Sources code. Soo in
explorer i Uncheck the SHOW FRIENDLY ERROR. so I can seee that

Microsoft OLE DB Provider for SQL Server error '80040e14'

Unclosed quotation mark before the character string 'a '.

like that. BUt in my Program I WANT to get this error Too.. In my
code. It always gooing exception.. :((
StringBuilder sb = new StringBuilder();
byte[] buf = new byte[8192];

HttpWebRequest request = (HttpWebRequest)WebRequest.Create(url);

try
{
HttpWebResponse response = (HttpWebResponse)request.GetResponse();
Stream resStream = response.GetResponseStream();

string tempString = null;
int count = 0;
do
{
count = resStream.Read(buf, 0, buf.Length);
if (count != 0)
{
tempString = Encoding.ASCII.GetString(buf, 0, count);
sb.Append(tempString);
}
Application.DoEvents();
}
while (count > 0);
resStream.Close();
response.Close();

if (File.Exists(dosya) == true) { File.Delete(dosya); }
StreamWriter writer = File.CreateText(dosya);
writer.WriteLine(sb.ToString());
writer.Close();
}
catch (Exception)
{
MessageBox.Show("Connection Failed !!"+url,"NO !!");
}

Feb 18 '06 #1
5 1069
Could you post your complete source?
It sounds as though you are passing the querystring to an SQL database,
that is where your error is probably originating. SQL statements don't
like single quotes, and applications that allow them are prone to SQL
injection attacks..
If you wanted to catch the error manually you should use the 'finally'
statement.

try{
//some code
}
catch{
//some code
}
finally{
if (File.Exists(dosya) == true) { File.Delete(dosya); }
StreamWriter writer = File.CreateText(dosya);
writer.WriteLine(sb.ToString());
writer.Close();
}

Feb 19 '06 #2
butt when I try get error . I am looking step by step.. it comes to
HttpWebResponse response = (HttpWebResponse)request.GetResponse();
And Get response "HTTP 500 INTERNAL ERROR " and goes to CATCH BUT not
goes to under the code. Too
Stream resStream = response.GetResponseStream();

So I don'T get sources code of Site in resStream . :((

Feb 19 '06 #3
HElpp ?? :(

Feb 20 '06 #4
Where is your SQL statement?

The error you are recieving is due to your SQL statement, NOT your
HttpWebResponse statement.

Try googling "Microsoft OLE DB Provider for SQL Server error '80040e14'"

Feb 22 '06 #5
The reason you will be getting the error is because the site is
actually returning a 500 error when you call it with this URL:
site.com/news.asp?id=55a

This is because the parameter ID probably is expecting a numeric value.
55a is not a numeric value.
Probably whats happening on the server end of 'site.com/news.asp' is
that the server side code is collecting the value of ID and casting it
to an integer.
Of course it then throws an exception and dies, probably with a 500
error.

Try pasting your URL "site.com/news.asp?id=55a" into a web browser and
see if you get a Server Error and an equivalent error code of 500.

Essentially the problem is not with your code.

SN

Feb 22 '06 #6

This discussion thread is closed

Replies have been disabled for this discussion.

Similar topics

2 posts views Thread by lawrence | last post: by
33 posts views Thread by Lalatendu Das | last post: by
1 post views Thread by liuhaoran | last post: by
4 posts views Thread by sid | last post: by

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.