Problem Populating Repeater

  • Thread starter Thread starter Roger
  • Start date Start date
R

Roger

Hi:
Can anyone tell me why my datagrid doesn't populate with query results. For
some reason, I get "System.Byte[]" when I run the following query:

Dim oConn As OdbcConnection = New OdbcConnection("DSN")
Dim oCmd As OdbcCommand = New OdbcCommand("SELECT TOP 1 * FROM Table1",
gridConn)
Dim dr As OdbcDataReader

oConn.Open()
dr = oCmd.ExecuteReader()

If dr.HasRows() Then
dr.Read()
Label1.Text = dr.GetString(0)
Label2.Text = dr.GetString(1)
dr.Close()

oCmd.CommandText = "SELECT * FROM Table2"
dr = oCmd.ExecuteReader()
dg1.DataSource = dr
dg1.DataBind()
End If
 
Where does System.Byte[] appear? It looks like what you are doing is putting
the table into the grid, but you dont use the grid in this fashion. When
the rendering takes place, the control looks for defined properties, or
calls object.ToString(). In your case the latter is being called. Take a
look at DataTables and DataViews. If not, load each row into a class and
pass the class to the DataSource property. You will need to define the
properties for the items using the Properties of the DataGrid.

HTH

Nick.
 
Back
Top