I'm writing an ASP.NET 2.0 page in VS2008. In my Page_Load method I have the following:
DataTable table = new DataTable();
SqlDataAdapter adapter = new SqlDataAdapter();
using (SqlConnection connection = new SqlConnection(conString)) {
using (SqlCommand command = new SqlCommand(cmdString, connection)) {
adapter.SelectCommand = command;
rowCount = adapter.Fill(table);
}
}
What have I done wrong?
The first time I execute the page, it works fine (Fill returns one row). If I run (Debug) the page a second time, I get zero rows. Likewise if the page is running, and I modify one of the parameters in the URL so that the cmdString changes, I get zero rows. If I make a trivial code change to force a re-compile, the page will again work.