Showing posts with label database. Show all posts
Showing posts with label database. Show all posts

Saturday, March 31, 2012

System.Drawing.Text font question

Hello,

I've looked for answer to this everywhere but with no luck..

I need to dynamically create graphic text from database values. I've got this working fine if I use arial as the font but I want to use another font.

Now - presumably I can use any font installed on the server? But it doesn't seem to work. I want to use a font called blurLight but it just outputs in arial (I think - it's a standard font anyway)

Is there anything else I need to do to make other fonts available to asp.net other than just installing them on the server???

Thank you.Post some code so we can have a looksie
Alright - I will

<%@. Page Language="VB" Debug="True" %>
<%@. Import Namespace="System.Drawing" %>
<%@. Import Namespace="System.Drawing.Imaging" %>
<%@. Import Namespace="System.Drawing.Text" %>
<%
' Declare Vars
Dim objBMP As System.Drawing.Bitmap
Dim objGraphics As System.Drawing.Graphics
Dim objFont As System.Drawing.Font

objBMP = New Bitmap(100, 30)

objGraphics = System.Drawing.Graphics.FromImage(objBMP)

objGraphics.Clear(Color.Green)

objGraphics.TextRenderingHint = TextRenderingHint.AntiAlias

objFont = New Font("Arial", 16, FontStyle.Bold)

objGraphics.DrawString("Hello World", objFont, Brushes.White, 3, 3)

Response.ContentType = "image/GIF"
objBMP.Save(Response.OutputStream, ImageFormat.Gif)

objFont.Dispose()
objGraphics.Dispose()
objBMP.Dispose()
%

That code works fine but when I replace Arial with the font I want to use - it doesn't work..

Any ideas??

System.FormatException: Input string was not in a correct format

Hello all,

I'm looking for a long time to find out what's wrong, but I can't find the mistake...
The connection to the database works correctly (Select,..), but when I set up the Insert-Command by clicking a button I get the following exception. Does anybody can help me and tell me what's wrong?!

Thank you for helping!

Exception:
System.FormatException: Input string was not in a correct format. at System.Number.ParseInt32(String s, NumberStyles style, NumberFormatInfo info) at System.String.System.IConvertible.ToInt32(IFormatProvider provider) at System.Convert.ChangeType(Object value, Type conversionType, IFormatProvider provider) at System.Data.OleDb.OleDbParameter.GetParameterValue() at System.Data.OleDb.OleDbParameter.GetParameterScale() at System.Data.OleDb.OleDbParameter.BindParameter(Int32 i, DBBindings bindings, tagDBPARAMBINDINFO[] bindInfo) at System.Data.OleDb.OleDbCommand.CreateAccessor() at System.Data.OleDb.OleDbCommand.InitializeCommand(CommandBehavior behavior, Boolean throwifnotsupported) at System.Data.OleDb.OleDbCommand.ExecuteCommand(CommandBehavior behavior, Object& executeResult) at System.Data.OleDb.OleDbCommand.ExecuteReaderInternal(CommandBehavior behavior, String method) at System.Data.OleDb.OleDbCommand.ExecuteNonQuery() at roomplaner.ObjektHinzu.Anlegen_Click(Object sender, EventArgs e) in C:\Inetpub\...\ObjektHinzu.aspx.vb:line 107

line 107 --> Command.ExecuteNonQuery()


Dim Command As New OleDbCommand

'create OleDb database connection
Dim SQL_CONNECTION_STRING As String = "Provider=SQLOLEDB;Server=...;...."
Command.Connection = New OleDbConnection(SQL_CONNECTION_STRING)

'create SQL statement for INSERT into table
Command.CommandText = "INSERT INTO t_object (Name, ObjectType, Category, Manufactor, Length, Width, Height, Text_Short, Text_Long, URL_Pic_Small, URL_Pic_Big, URL_Pic_Plan, URL_VET, VET_ObjectName, Material, Color, Price, ObjectLink, Comment, MaxSceneCount) values (?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?)"
Command.CommandType = CommandType.Text

'add input parameters and values to INSERT statement
Command.Parameters.Add("@dotnet.itags.org.Name", OleDbType.VarChar, 100).Value = O_Name.Text
Command.Parameters.Add("@dotnet.itags.org.ObjectType", OleDbType.BigInt, 8).Value = O_ObjectType.SelectedValue
Command.Parameters.Add("@dotnet.itags.org.Category", OleDbType.BigInt, 8).Value = O_Category.SelectedValue
Command.Parameters.Add("@dotnet.itags.org.Manufactor", OleDbType.BigInt, 8).Value = O_Manufactor.SelectedValue
Command.Parameters.Add("@dotnet.itags.org.Length", OleDbType.Integer, 4).Value = O_Length.Text
Command.Parameters.Add("@dotnet.itags.org.Width", OleDbType.Integer, 4).Value = O_Width.Text
Command.Parameters.Add("@dotnet.itags.org.Height", OleDbType.Integer, 4).Value = O_Height.Text
Command.Parameters.Add("@dotnet.itags.org.Text_Short", OleDbType.VarChar, 100).Value = O_Text_Short.Text
Command.Parameters.Add("@dotnet.itags.org.Text_Long", OleDbType.VarChar, 500).Value = O_Text_Long.Text

Command.Parameters.Add("@dotnet.itags.org.URL_Pic_Small", OleDbType.VarChar, 100).Value = "0"
Command.Parameters.Add("@dotnet.itags.org.URL_Pic_Big", OleDbType.VarChar, 100).Value = "0"
Command.Parameters.Add("@dotnet.itags.org.URL_Pic_Plan", OleDbType.VarChar, 100).Value = "0"

Command.Parameters.Add("@dotnet.itags.org.URL_VET", OleDbType.VarChar, 100).Value = "0"
Command.Parameters.Add("@dotnet.itags.org.VET_ObjectName", OleDbType.VarChar, 50).Value = O_VET_ObjectName.Text
Command.Parameters.Add("@dotnet.itags.org.Material", OleDbType.BigInt, 8).Value = O_Material.SelectedValue
Command.Parameters.Add("@dotnet.itags.org.Color", OleDbType.BigInt, 8).Value = O_Color.SelectedValue
Command.Parameters.Add("@dotnet.itags.org.Price", OleDbType.VarChar, 50).Value = O_Price.Text
Command.Parameters.Add("@dotnet.itags.org.ObjectLink", OleDbType.VarChar, 100).Value = O_ObjectLink.Text
Command.Parameters.Add("@dotnet.itags.org.Comment", OleDbType.VarChar, 100).Value = O_Comment.Text
Command.Parameters.Add("@dotnet.itags.org.MaxSceneCount", OleDbType.Integer, 4).Value = O_MaxSceneCount.Text

Try
Command.Connection.Open()
Command.ExecuteNonQuery() 'save record

Catch ex As Exception
Response.Write("Exception:")
Response.Write(ex.ToString)
End Try

Command.Connection.Close()
End Sub

The error is associated with a call to System.Number.ParseInt32(). That tells me that one of the parameters is expected to contain an integer or a string representation of an integer but does not. Identify integer parameters. Then in the debugger, determine if any of them are:
1. Not assigned. If a string is provided, is it an empty string?
2. Contains other characters than digits?
These two cases will generate that exception. (The .net docs for Convert.ToInt32 say FormatException will occur when:value does not consist of an optional sign followed by a sequence of digits (zero through nine).)

Wednesday, March 28, 2012

System.InvalidCastException: Specified cast is not valid.

i'm retrieving data with Repeater from Sql Database. i have color colums in the table.. such as color1, color2, color3, color4 and columns type Nvarchar.

i implemented below the function to get team colors instead of characters in the table cells

---- function -----

string Team_Colours(string color)
{
switch (color)
{
case "WHITE" :
color = "#FFFFFF";
break;

case "BLACK" :
color = "#000000";
break;

case "RED" :
color = "#FF0000";
break;
case "" : // i think problem is here

color = "";
break;
}

return color;
}

-----------

if all color colums are not null, everything okay.. but, i'm getting below the error if any color colums is null..

------error-----

Exception Details: System.InvalidCastException: Specified cast is not valid.

Line 159: <td bgcolor="<%# Team_Colors((string) DataBinder.Eval(Container.DataItem, "color4")) %>"
------------
how can i solve this problem ?

thanks..If it's Null at times, try Switch(color.ToString())
Or add the .ToString to where the color is actually being read from the database.

Hope this helps, but may need to see more code...

Zath
i tried that Switch(color.ToString()) but same eror :(
it's ok, thanks Zath..

<%# Team_Colors(DataBinder.Eval(Container.DataItem, "color1").ToString()) %>
<%# Team_Colors(DataBinder.Eval(Container.DataItem, "color2").ToString()) %>
<%# Team_Colors(DataBinder.Eval(Container.DataItem, "color3").ToString()) %>
<%# Team_Colors(DataBinder.Eval(Container.DataItem, "color4").ToString()) %>
I just tried your function and it works ok for me.
Are there any other colors in the database not accounted for?

Have you tried setting a break point in your code to help debug?

Maybe a little more code might help.

Zath

System.InvalidOperationException: Connection must be valid and open

Hi.
I am using this function tu execute updates to a MySql database from a sql
string, but I am getting a System.InvalidOperationException: Connection
must be valid and open.
Database queries work fine, but I cant update the source. Am I missing
something?
Thanks, Alejandro.
public static bool updateSource(string sql)
{
MySqlConnection conn = new MySqlConnection(myConnectionString);
MySqlCommand command = new MySqlCommand(sql,conn);
command.CommandType = CommandType.Text;
try
{
command.ExecuteNonQuery();
return true;
}
catch (Exception)
{return false;}
finally
{
conn.Close();
}Hello Alejandro Penate-Diaz,
Exactly what the error message says... You need to have a valid *and* open
connection.
Try adding conn.Open() before the command.ExecuteNonQuery() method.
Matt Berther
http://www.mattberther.com

> Hi.
> I am using this function tu execute updates to a MySql database from a
> sql string, but I am getting a System.InvalidOperationException:
> Connection must be valid and open.
> Database queries work fine, but I cant update the source. Am I missing
> something?
> Thanks, Alejandro.
> public static bool updateSource(string sql)
> {
> MySqlConnection conn = new MySqlConnection(myConnectionString);
> MySqlCommand command = new MySqlCommand(sql,conn);
> command.CommandType = CommandType.Text;
> try
> {
> command.ExecuteNonQuery();
> return true;
> }
> catch (Exception)
> {return false;}
> finally
> {
> conn.Close();
> }
>
Heyy, thanks!! Problem was that I was like copy-paste and didn't realize
that DataAdapter.Fill actualy does that for me but in this case I have to do
it by myself. ;-)
Thanks a lot!
Alejandro.
"Matt Berther" <mberther@.hotmail.com> wrote in message
news:6852859632389121357049404@.news.microsoft.com...
> Hello Alejandro Penate-Diaz,
> Exactly what the error message says... You need to have a valid *and* open
> connection.
> Try adding conn.Open() before the command.ExecuteNonQuery() method.
> --
> Matt Berther
> http://www.mattberther.com
>
>

System.InvalidOperationException: Connection must be valid and open

Hi.

I am using this function tu execute updates to a MySql database from a sql
string, but I am getting a System.InvalidOperationException: Connection
must be valid and open.

Database queries work fine, but I cant update the source. Am I missing
something?

Thanks, Alejandro.

public static bool updateSource(string sql)

{

MySqlConnection conn = new MySqlConnection(myConnectionString);

MySqlCommand command = new MySqlCommand(sql,conn);

command.CommandType = CommandType.Text;

try

{

command.ExecuteNonQuery();

return true;

}

catch (Exception)

{return false;}

finally

{

conn.Close();

}Hello Alejandro Penate-Diaz,

Exactly what the error message says... You need to have a valid *and* open
connection.

Try adding conn.Open() before the command.ExecuteNonQuery() method.

--
Matt Berther
http://www.mattberther.com

> Hi.
> I am using this function tu execute updates to a MySql database from a
> sql string, but I am getting a System.InvalidOperationException:
> Connection must be valid and open.
> Database queries work fine, but I cant update the source. Am I missing
> something?
> Thanks, Alejandro.
> public static bool updateSource(string sql)
> {
> MySqlConnection conn = new MySqlConnection(myConnectionString);
> MySqlCommand command = new MySqlCommand(sql,conn);
> command.CommandType = CommandType.Text;
> try
> {
> command.ExecuteNonQuery();
> return true;
> }
> catch (Exception)
> {return false;}
> finally
> {
> conn.Close();
> }
Heyy, thanks!! Problem was that I was like copy-paste and didn't realize
that DataAdapter.Fill actualy does that for me but in this case I have to do
it by myself. ;-)

Thanks a lot!
Alejandro.

"Matt Berther" <mberther@.hotmail.com> wrote in message
news:6852859632389121357049404@.news.microsoft.com. ..
> Hello Alejandro Penate-Diaz,
> Exactly what the error message says... You need to have a valid *and* open
> connection.
> Try adding conn.Open() before the command.ExecuteNonQuery() method.
> --
> Matt Berther
> http://www.mattberther.com
>> Hi.
>>
>> I am using this function tu execute updates to a MySql database from a
>> sql string, but I am getting a System.InvalidOperationException:
>> Connection must be valid and open.
>>
>> Database queries work fine, but I cant update the source. Am I missing
>> something?
>>
>> Thanks, Alejandro.
>>
>> public static bool updateSource(string sql)
>>
>> {
>>
>> MySqlConnection conn = new MySqlConnection(myConnectionString);
>>
>> MySqlCommand command = new MySqlCommand(sql,conn);
>>
>> command.CommandType = CommandType.Text;
>>
>> try
>>
>> {
>>
>> command.ExecuteNonQuery();
>>
>> return true;
>>
>> }
>>
>> catch (Exception)
>>
>> {return false;}
>>
>> finally
>>
>> {
>>
>> conn.Close();
>>
>> }
>>
OH Good u found ur Error...
Enjoy
Patrick

"Alejandro Penate-Diaz" wrote:

> Heyy, thanks!! Problem was that I was like copy-paste and didn't realize
> that DataAdapter.Fill actualy does that for me but in this case I have to do
> it by myself. ;-)
> Thanks a lot!
> Alejandro.
> "Matt Berther" <mberther@.hotmail.com> wrote in message
> news:6852859632389121357049404@.news.microsoft.com. ..
> > Hello Alejandro Penate-Diaz,
> > Exactly what the error message says... You need to have a valid *and* open
> > connection.
> > Try adding conn.Open() before the command.ExecuteNonQuery() method.
> > --
> > Matt Berther
> > http://www.mattberther.com
> >> Hi.
> >>
> >> I am using this function tu execute updates to a MySql database from a
> >> sql string, but I am getting a System.InvalidOperationException:
> >> Connection must be valid and open.
> >>
> >> Database queries work fine, but I cant update the source. Am I missing
> >> something?
> >>
> >> Thanks, Alejandro.
> >>
> >> public static bool updateSource(string sql)
> >>
> >> {
> >>
> >> MySqlConnection conn = new MySqlConnection(myConnectionString);
> >>
> >> MySqlCommand command = new MySqlCommand(sql,conn);
> >>
> >> command.CommandType = CommandType.Text;
> >>
> >> try
> >>
> >> {
> >>
> >> command.ExecuteNonQuery();
> >>
> >> return true;
> >>
> >> }
> >>
> >> catch (Exception)
> >>
> >> {return false;}
> >>
> >> finally
> >>
> >> {
> >>
> >> conn.Close();
> >>
> >> }
> >>
>

Monday, March 26, 2012

System.Net.Mail issue - html AlternateView losing period in href

I have setup some code that grabs HTML from our database and attaches it as an AlternateView
--
AlternateView htmlView = AlternateView.CreateAlternateViewFromString(htmlSB.ToString(),Encoding.GetEncoding(0),MediaTypeNames.Text.Html);
--
I am dumping it to a text file locally. In the instance where there is a wrap in the body which contains an a href, and there is a period just AFTER the wrap, it drops the period
ex of the physical email file:
blah blah blah blah <a href="http://links.10026.com/?link=http://forums.asp=
.net>Asp Forums</a>blah blah blah blah bla=
(note the period on the new line)
shows up as -
blah blah blah blah <a href="http://links.10026.com/?link=http://forums.aspnet>Asp Forums</a>blah blah blah blah bla
(note the missing period between asp and net)
Any ideas?
thanks
m

Since I have not gotten a response at all, should I assume that this is an unfixable bug and abandon system.net.mail?

thanks

Saturday, March 24, 2012

System.Net.Webclient screen scraping: how to gracefully handle 403 (and other) errors?

I've written a very small ASP.NET page to scrape thousands of pages of
content based on database IDs. It loops through a dataset to get the IDs. It
worked well in testing but now I am getting an annoying 403 error that
causes the script to abort halfway through my download.

I am wondering if there is a way in ASP.NET to have my code ignore 403
errors and other network errors, catch the error, and iterate to the next ID
in the dataset rather than aborting the whole job.

My code appears below. Thank you in advance.

-KF

string strConnection;

strConnection = ConfigurationSettings.AppSettings["connwhatever"];

SqlConnection conn = new SqlConnection(strConnection);

string query = // [my query];

SqlDataAdapter a = new SqlDataAdapter(query, conn);

DataSet s = new DataSet();

a.Fill(s);

int counter = 0;

foreach (DataRow dr in s.Tables[0].Rows)

{

counter++;

System.Net.WebClient wc = new WebClient();

string strData =
wc.DownloadString("http://whatever.org/article.asp?articleid=" +
dr[0].ToString());

FileStream fstream = new FileStream(@dotnet.itags.org."c:\whateverpath\" + dr[0].ToString() +
".htm", FileMode.Create, FileAccess.Write);

StreamWriter stream = new StreamWriter(fstream);

stream.Write(strData);

stream.Close();

fstream.Close();please read chapter on try/catch

-- bruce (sqlwork.com)

kenfine@.nospam.nospam wrote:

Quote:

Originally Posted by

I've written a very small ASP.NET page to scrape thousands of pages of
content based on database IDs. It loops through a dataset to get the IDs. It
worked well in testing but now I am getting an annoying 403 error that
causes the script to abort halfway through my download.
>
I am wondering if there is a way in ASP.NET to have my code ignore 403
errors and other network errors, catch the error, and iterate to the next ID
in the dataset rather than aborting the whole job.
>
My code appears below. Thank you in advance.
>
-KF
>
string strConnection;
>
strConnection = ConfigurationSettings.AppSettings["connwhatever"];
>
SqlConnection conn = new SqlConnection(strConnection);
>
string query = // [my query];
>
SqlDataAdapter a = new SqlDataAdapter(query, conn);
>
DataSet s = new DataSet();
>
a.Fill(s);
>
int counter = 0;
>
foreach (DataRow dr in s.Tables[0].Rows)
>
{
>
counter++;
>
System.Net.WebClient wc = new WebClient();
>
string strData =
wc.DownloadString("http://whatever.org/article.asp?articleid=" +
dr[0].ToString());
>
FileStream fstream = new FileStream(@."c:\whateverpath\" + dr[0].ToString() +
".htm", FileMode.Create, FileAccess.Write);
>
StreamWriter stream = new StreamWriter(fstream);
>
stream.Write(strData);
>
stream.Close();
>
fstream.Close();
>
>
>
>


Understand try/catch generally. What event(s) should I be trying to catch?

Thank you,
-KF

"bruce barker" <nospam@.nospam.comwrote in message
news:%23F79bSINHHA.3288@.TK2MSFTNGP03.phx.gbl...

Quote:

Originally Posted by

please read chapter on try/catch
>
-- bruce (sqlwork.com)
>
kenfine@.nospam.nospam wrote:

Quote:

Originally Posted by

>I've written a very small ASP.NET page to scrape thousands of pages of
>content based on database IDs. It loops through a dataset to get the IDs.
>It worked well in testing but now I am getting an annoying 403 error that
>causes the script to abort halfway through my download.
>>
>I am wondering if there is a way in ASP.NET to have my code ignore 403
>errors and other network errors, catch the error, and iterate to the next
>ID in the dataset rather than aborting the whole job.
>>
>My code appears below. Thank you in advance.
>>
>-KF
>>
>string strConnection;
>>
>strConnection = ConfigurationSettings.AppSettings["connwhatever"];
>>
>SqlConnection conn = new SqlConnection(strConnection);
>>
>string query = // [my query];
>>
>SqlDataAdapter a = new SqlDataAdapter(query, conn);
>>
>DataSet s = new DataSet();
>>
>a.Fill(s);
>>
>int counter = 0;
>>
>foreach (DataRow dr in s.Tables[0].Rows)
>>
>{
>>
>counter++;
>>
>System.Net.WebClient wc = new WebClient();
>>
>string strData =
>wc.DownloadString("http://whatever.org/article.asp?articleid=" +
>dr[0].ToString());
>>
>FileStream fstream = new FileStream(@."c:\whateverpath\" +
>dr[0].ToString() + ".htm", FileMode.Create, FileAccess.Write);
>>
>StreamWriter stream = new StreamWriter(fstream);
>>
>stream.Write(strData);
>>
>stream.Close();
>>
>fstream.Close();
>>
>>
>>


Hello KF,

Based on your description, you're using the webclient class to request many
web pages programmatically in ASP.NET page code. However, since some page
may raise some exception, your client loop code in ASP.NET page break,
correct?

As for the 403 error, it is normally caused by the security authorization
checking at server-side fails. I'm not sure whether there is any other
particular scenario here, however, if what you want is simply captuer and
ignore such error and continue the loop, you can just add a try catch block
around your webclient class's downloadXXX method call and if any exception
captured you can simply ignore it and skip the current loop. e.g.

=======================
foreach (DataRow dr in s.Tables[0].Rows)

{

counter++;

System.Net.WebClient wc = new WebClient();

try
{

string strData =
wc.DownloadString("http://whatever.org/article.asp?articleid=" +
dr[0].ToString());

}catch(Exception ex)
{
//ignore and continue the loop
}

...........................

}
=========================

Does this work for your scenario?

Sincerely,

Steven Cheng

Microsoft MSDN Online Support Lead

==================================================

Get notification to my posts through email? Please refer to
http://msdn.microsoft.com/subscript...ault.aspx#notif
ications.

Note: The MSDN Managed Newsgroup support offering is for non-urgent issues
where an initial response from the community or a Microsoft Support
Engineer within 1 business day is acceptable. Please note that each follow
up response may take approximately 2 business days as the support
professional working with you may need further investigation to reach the
most efficient resolution. The offering is not appropriate for situations
that require urgent, real-time or phone-based interactions or complex
project analysis and dump analysis issues. Issues of this nature are best
handled working with a dedicated Microsoft Support Engineer by contacting
Microsoft Customer Support Services (CSS) at
http://msdn.microsoft.com/subscript...rt/default.aspx.

==================================================

This posting is provided "AS IS" with no warranties, and confers no rights.
For webclient or HttpWebRequest, it normally will throw a
System.Net.WebException, however, any exception can be handled by the super
class "Exception". So you can use either

try
{
}catch(Exception)
{

}

or

try
{
}catch(WebException)
{

}

Sincerely,

Steven Cheng

Microsoft MSDN Online Support Lead

This posting is provided "AS IS" with no warranties, and confers no rights.
You can specify error documents for specific error-codes.

In your web.config, add the following entries in <system.websection:

<customErrors>
<error statusCode="403" redirect="403.aspx"/>
</customErrors>

Note that generally, 403 would be given by the web server and not be the
ASP.Net engine. At times, when the authentication fails, 403 may be returned
by an IHttpModule - like the authentication modules (NTML, Kerberos, Digest
etc).

--
Happy Hacking,
Gaurav Vaish | www.mastergaurav.com
www.edujini-labs.com
http://eduzine.edujinionline.com
-------------

<kenfine@.nospam.nospamwrote in message
news:%23SginPGNHHA.4916@.TK2MSFTNGP06.phx.gbl...

Quote:

Originally Posted by

I've written a very small ASP.NET page to scrape thousands of pages of
content based on database IDs. It loops through a dataset to get the IDs.
It worked well in testing but now I am getting an annoying 403 error that
causes the script to abort halfway through my download.
>
I am wondering if there is a way in ASP.NET to have my code ignore 403
errors and other network errors, catch the error, and iterate to the next
ID in the dataset rather than aborting the whole job.
>
My code appears below. Thank you in advance.


This worked great for my scenario. Thanks very much to everyone for the
timely assistance.

-KF

"Steven Cheng[MSFT]" <stcheng@.online.microsoft.comwrote in message
news:FYKH6FJNHHA.2024@.TK2MSFTNGHUB02.phx.gbl...

Quote:

Originally Posted by

Hello KF,
>
Based on your description, you're using the webclient class to request
many
web pages programmatically in ASP.NET page code. However, since some page
may raise some exception, your client loop code in ASP.NET page break,
correct?
>
As for the 403 error, it is normally caused by the security authorization
checking at server-side fails. I'm not sure whether there is any other
particular scenario here, however, if what you want is simply captuer and
ignore such error and continue the loop, you can just add a try catch
block
around your webclient class's downloadXXX method call and if any exception
captured you can simply ignore it and skip the current loop. e.g.
>
=======================
foreach (DataRow dr in s.Tables[0].Rows)
>
{
>
counter++;
>
System.Net.WebClient wc = new WebClient();
>
try
{
>
string strData =
wc.DownloadString("http://whatever.org/article.asp?articleid=" +
dr[0].ToString());
>
}catch(Exception ex)
{
//ignore and continue the loop
}
>
...........................
>
}
=========================
>
Does this work for your scenario?
>
Sincerely,
>
Steven Cheng
>
Microsoft MSDN Online Support Lead
>
>
>
==================================================
>
Get notification to my posts through email? Please refer to
http://msdn.microsoft.com/subscript...ault.aspx#notif
ications.
>
>
>
Note: The MSDN Managed Newsgroup support offering is for non-urgent issues
where an initial response from the community or a Microsoft Support
Engineer within 1 business day is acceptable. Please note that each follow
up response may take approximately 2 business days as the support
professional working with you may need further investigation to reach the
most efficient resolution. The offering is not appropriate for situations
that require urgent, real-time or phone-based interactions or complex
project analysis and dump analysis issues. Issues of this nature are best
handled working with a dedicated Microsoft Support Engineer by contacting
Microsoft Customer Support Services (CSS) at
http://msdn.microsoft.com/subscript...rt/default.aspx.
>
==================================================
>
>
>
This posting is provided "AS IS" with no warranties, and confers no
rights.
>