By using this site, you agree to our updated Privacy Policy and our Terms of Use. Manage your Cookies Settings.
429,435 Members | 2,036 Online
Bytes IT Community
+ Ask a Question
Need help? Post your question and get tips & solutions from a community of 429,435 IT Pros & Developers. It's quick & easy.

Problem Populating Repeater

P: n/a
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
Nov 18 '05 #1
Share this Question
Share on Google+
1 Reply


P: n/a
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.
"Roger" <Th******@Superhero.com> wrote in message
news:uC*************@TK2MSFTNGP11.phx.gbl...
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

Nov 18 '05 #2

This discussion thread is closed

Replies have been disabled for this discussion.