I have simple ASP.NET app (.NET 1.1) that allows the user to build a SQL query and show the results in a datagrid. It works OK, except that the first row does not show in the datagrid. If I run the query directly in SQL Server Query Analyzer, I get 17 rows. When I run it through the app, I get 16 rows.
I know it has to be something pretty simple I am doing wrong. Can somebody throw me a bone?
Thanks,
Jason
Code:
Dim cn As New SqlConnection(Application("cnString"))
Dim cmd As New SqlCommand
Dim dr As SqlDataReader
Dim strStatement As String = Me.txtQuery.Text
cmd.CommandText = "SELECT columns FROM table WHERE base condition AND " & strStatement
cmd.CommandType = CommandType.Text
cmd.Connection = cn
cn.Open()
dr = cmd.ExecuteReader(CommandBehavior.Default)
dr.Read()
Me.dgResults.DataSource() = dr
Me.dgResults.DataBind()
cn.Close()
dr.Close()
I know it has to be something pretty simple I am doing wrong. Can somebody throw me a bone?
Thanks,
Jason