Re: Arraylist.remove problem?? Please help.



ok tried to do that and for some reason it can't open the reader now.
Bjorn Abelli wrote:
"Extremest" wrote...

[snipped things I'm jealous of...]

I know that the big slow down for it is the loop.
so if the group thing can become a reality
I know it will speed it up big time.

I have only glanced on this thread before, so I don't think I have followed
all intricate details on what you want to do, but when you say that "the big
slow down for it is the loop", I looked at it, and saw some curious things.

Why are you opening and closing the connection so many times?

Network access is costly, even if it's only on the local machine.

And from what I understand, you use the same connection string for both
"conn" and "connu", so I don't see the point in having both.

Just to illustrate, I have hastily made some alterations in your "Main" and
"getheaders", which "should" work more efficiently.



static void Main(string[] args)
{
while (numbfound > 0)
{
numbfound = 0;

// Open the connection only one time for the loop

conn.ConnectionString = myConnectionString;
conn.Open();
cmd.Connection = conn;
cmdu.Connection = conn;

for (int x = 0; x < groups.Length; x++)
{
table = reg.Replace(groups[x], "");
group = groups[x];
getheaders();
find();
master.Clear();
prepared = false;
}

// And then we close it...

conn.Close();
Console.WriteLine(numbfound);
}
}

static void getheaders()
{
// No need to open a new connection, as conn and cmd are static

cmd.CommandText =
"select * from " + table +
" where subject like '%(%/%)%'" +
" and subject like '%\"%\"%' limit 400000";

MySql.Data.MySqlClient.MySqlDataReader reader;
reader = cmd.ExecuteReader();
master = new ArrayList();
while (reader.Read())
{
Header h = new Header(reader.GetValue(0).ToString(),
reader.GetValue(1).ToString(), reader.GetValue(3).ToString(),
reader.GetValue(2).ToString(), reader.GetValue(4).ToString(),
reader.GetValue(5).ToString());
master.Add(h);
}
reader.Close();
}

----------------------------------

There are probably many other things to make it faster too,
but these were some obvious ones...

/// Bjorn A

.



Relevant Pages

  • Re: Arraylist.remove problem?? Please help.
    ... you use the same connection string for both ... static void Main ... cmdu.Connection = conn; ... MySql.Data.MySqlClient.MySqlDataReader reader; ...
    (microsoft.public.dotnet.languages.csharp)
  • Three Phases To Email Sensitivity
    ... the associationphase, the connection phase, and the ... They should have the right words thatthe reader can transform back ... When writing your response, you willwant to make ... If the topic is about apples, you donot want to add an orange ...
    (comp.lang.vhdl)
  • Re: garbage collection
    ... You can not return reader after the connection is closed. ... But to return a dataReader you need to keep the connection open. ... Also, If your application>> doesnt allow database connection pooling, you need to dispose your> database ...
    (microsoft.public.dotnet.framework.aspnet)
  • Re: CommandBehavior.CloseConnection question
    ... > When you close the reader, the connection is closed if you use ... Dim dbReader as SqlDataReader ... Dim ConnectionString as String ...
    (microsoft.public.dotnet.framework.adonet)
  • Re: Multi-threaded apps and data readers
    ... RightHand .NET consulting & development www.rthand.com ... Blog: http://cs.rthand.com/blogs/blog_with_righthand/ ... So if I kept the connection open all ... commands reader, how would I prevent the readers from clashing or do ...
    (microsoft.public.dotnet.framework.adonet)

Loading