Problem Populating Repeater

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
 
N

Nick

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.
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Members online

No members online now.

Forum statistics

Threads
473,755
Messages
2,569,536
Members
45,009
Latest member
GidgetGamb

Latest Threads

Top