M
Marlon B. Rabara
Testing my DAL and the following only returns one row:
SqlConnection cnn = new SqlConnection("Persist Security
Info=False;Integrated Security=SSPI;database=Northwind;server=RXSERVER;");
SqlCommand cmd = new SqlCommand();
cmd.CommandText = "select * from Employees";
cmd.CommandType = CommandType.Text;
cmd.Connection = cnn;
cnn.Open();
SqlDataReader datareader = cmd.ExecuteReader(CommandBehavior.SingleRow);
while (datareader.Read())
{
Console.WriteLine(datareader.GetValue(0));
}
datareader.Close();
cnn.Close();
************************
I get one row and the next call to Read() evaluates to false. I watched the
profiler and the SQL statement is being called correctly. However, I am only
getting one row back and that is it. There are I believe a total of 10 recs.
Can anyone see what I'm doing wrong? Am I missing something in the
connection string for data readers to work properly?
SqlConnection cnn = new SqlConnection("Persist Security
Info=False;Integrated Security=SSPI;database=Northwind;server=RXSERVER;");
SqlCommand cmd = new SqlCommand();
cmd.CommandText = "select * from Employees";
cmd.CommandType = CommandType.Text;
cmd.Connection = cnn;
cnn.Open();
SqlDataReader datareader = cmd.ExecuteReader(CommandBehavior.SingleRow);
while (datareader.Read())
{
Console.WriteLine(datareader.GetValue(0));
}
datareader.Close();
cnn.Close();
************************
I get one row and the next call to Read() evaluates to false. I watched the
profiler and the SQL statement is being called correctly. However, I am only
getting one row back and that is it. There are I believe a total of 10 recs.
Can anyone see what I'm doing wrong? Am I missing something in the
connection string for data readers to work properly?