datareader/datagrid will not work
I'm having so much trouble I've been trying to solve the following problem for hours and hours. what I'm trying to do is output an grid from a table, i'm using code behind and outputting to an <asp:datagrid>, or trying to, I had some severe problem with trying to make a login searching for username/password and couldn't output the userID but I solved it. somehow I think the problems are related, anyway, here's the code
Dim dgrSongLog As DataGrid
Dim strConnection As String = Application("strconnection")
Dim objConnection As New SqlConnection(strConnection)
objConnection.Open()
Dim strProcName = "SELECT * FROM tblSongLog WHERE uid ='" & Request.QueryString("uid") & "' ORDER BY inserted DESC"
Dim objCommand As New SqlCommand(strProcName, objConnection)
Dim objReader As SqlDataReader = objCommand.ExecuteReader()
dgrSongLog.DataSource = objReader
dgrSongLog.DataBind()
AND HERE'S THE ERROR MESSAGE
Exception Details: System.NullReferenceException: Object reference not set to an instance of an object.
Source Error:
Line 54: Dim objReader As SqlDataReader = objCommand.ExecuteReader()
Line 55:
Line 56: dgrSongLog.DataSource = objReader
Line 57: dgrSongLog.DataBind()
Line 58:
it doesn't seem the matter if I'm trying with oledb or sql, datagrid och datareader, it just won't budge on the instansiating. I'm pulling my hair here.
Sincerely
Bennie
|