S
Shapper
Hello,
I have this code to bind a DataGrid to a DataReader when page loads:
Sub Page_Load(Sender As Object, e As EventArgs)
dgContent.DataSource = drContent
dgContent.DataBind()
End Sub
It's not working.
What is wrong?
Thanks,
Miguel
P.S: This is my DataReader Function:
Function drContent(ByVal page As String, ByVal name As String) As
System.Data.IDataReader
Dim connectionString As String =
System.Configuration.ConfigurationSettings.AppSettings("connectionString")
Dim dbConnection As System.Data.IDbConnection = New
System.Data.OleDb.OleDbConnection(connectionString)
Dim queryString As String = "SELECT [t_content].* FROM
[t_content] WHERE (([t_content].[page] = @page) AND ([t_content].[name]
= @name))"
Dim dbCommand As System.Data.IDbCommand = New
System.Data.OleDb.OleDbCommand
dbCommand.CommandText = queryString
dbCommand.Connection = dbConnection
Dim dbParam_page As System.Data.IDataParameter = New
System.Data.OleDb.OleDbParameter
dbParam_page.ParameterName = "@page"
dbParam_page.Value = page
dbParam_page.DbType = System.Data.DbType.String
dbCommand.Parameters.Add(dbParam_page)
Dim dbParam_name As System.Data.IDataParameter = New
System.Data.OleDb.OleDbParameter
dbParam_name.ParameterName = "@name"
dbParam_name.Value = name
dbParam_name.DbType = System.Data.DbType.String
dbCommand.Parameters.Add(dbParam_name)
dbConnection.Open
Dim dataReader As System.Data.IDataReader =
dbCommand.ExecuteReader(System.Data.CommandBehavior.CloseConnection)
Return dataReader
End Function
I have this code to bind a DataGrid to a DataReader when page loads:
Sub Page_Load(Sender As Object, e As EventArgs)
dgContent.DataSource = drContent
dgContent.DataBind()
End Sub
It's not working.
What is wrong?
Thanks,
Miguel
P.S: This is my DataReader Function:
Function drContent(ByVal page As String, ByVal name As String) As
System.Data.IDataReader
Dim connectionString As String =
System.Configuration.ConfigurationSettings.AppSettings("connectionString")
Dim dbConnection As System.Data.IDbConnection = New
System.Data.OleDb.OleDbConnection(connectionString)
Dim queryString As String = "SELECT [t_content].* FROM
[t_content] WHERE (([t_content].[page] = @page) AND ([t_content].[name]
= @name))"
Dim dbCommand As System.Data.IDbCommand = New
System.Data.OleDb.OleDbCommand
dbCommand.CommandText = queryString
dbCommand.Connection = dbConnection
Dim dbParam_page As System.Data.IDataParameter = New
System.Data.OleDb.OleDbParameter
dbParam_page.ParameterName = "@page"
dbParam_page.Value = page
dbParam_page.DbType = System.Data.DbType.String
dbCommand.Parameters.Add(dbParam_page)
Dim dbParam_name As System.Data.IDataParameter = New
System.Data.OleDb.OleDbParameter
dbParam_name.ParameterName = "@name"
dbParam_name.Value = name
dbParam_name.DbType = System.Data.DbType.String
dbCommand.Parameters.Add(dbParam_name)
dbConnection.Open
Dim dataReader As System.Data.IDataReader =
dbCommand.ExecuteReader(System.Data.CommandBehavior.CloseConnection)
Return dataReader
End Function