SQLDataReader stops responding after reading.

Joined
Oct 17, 2006
Messages
1
Reaction score
0
I have the following code, nothing out of the ordinary.

string conn = "integrated security=SSPI;Trusted_Connection=Yes;server=server;database=Datawarehouse";
SqlConnection conn1 = new SqlConnection(conn);
try
{
conn1.Open();
eventLog.WriteEntry("Opened Connection");
}
catch(Exception e45)
{
eventLog.WriteEntry("Error: " + e45.Message,System.Diagnostics.EventLogEntryType.Error);
}
CultureInfo culture = new CultureInfo( "en-US" );
string query56 = "SELECT EventName, WKS, Data, EventTime FROM DW_DataWarehouse WHERE EventName='Logon'";
SqlCommand myCommand = new SqlCommand(query56, conn1);
SqlDataReader reader = myCommand.ExecuteReader();

string opsdate1, endtime1, duration1, eventname1, data1, wks1, starttime1, signin1, airline1, terminal1;
int counter=0;
while (reader.Read())
{
counter = counter+1;
eventname1 = reader["EventName"].ToString().Trim();
data1 = reader["Data"].ToString().Trim();
wks1 = reader["WKS"].ToString().Trim();
starttime1 = reader["EventTime"].ToString().Trim();
int spaceposition = starttime1.IndexOf(" ");
opsdate1 = starttime1.Substring(0, spaceposition);
int usernameposition = data1.IndexOf("UserName=");
int firstquote1 = data1.Substring(usernameposition + 10, 10).IndexOf("\"");
signin1 = data1.Substring(usernameposition + 10, firstquote1);
terminal1 = wks1.Substring(3,1);
eventLog.WriteEntry("SqlDataReader, reader = " +reader.HasRows.ToString());
eventLog.WriteEntry("Workstation: " + wks1 + " COUNTER: " + counter.ToString());
}

conn1.Close();
reader.Close();


The SQLDataReader only reads the first 11 rows returned by the query and then stops responding, ie: nothing shows up in the EventLog. Anyone know why this might be happening? Any help is greatly appreciated.

Thanks
 
Last edited:

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Members online

No members online now.

Forum statistics

Threads
473,763
Messages
2,569,562
Members
45,038
Latest member
OrderProperKetocapsules

Latest Threads

Top