Solved

Datagrid not displaying all rows

Posted on 2012-03-29
5
316 Views
Last Modified: 2012-04-17
I am using VS 2008, SQL CE and VB.
I have a DataGrid that is bound to via a recordset.

When I update the data source for the DataGrid, data in the DataGrid's visible rows are displayed correctly. However if you scroll down, the cells below are blank with a big "X". When you scroll back up, the rows that were displaying data are now replaced with big "X".

Here's the code:

Me.MyDataGrid.Doc = DockStyle.Bottom

Dim cmd as New SqlCECommand()
Dim conn as New SqlCEConnection()
Dim rs as SqlCEResultSet
conn.ConnectString ="Data Source = '\data.sdf'; mode=Exclusive;"
cmd.CommandText = "SELECT * FROM table1"
rs = cmdExecuteResultSet(ResultSetOptions.Scrollable or ResultSetOptions.Updatable)

if rs.HasRows then
   Me.MyDataGrid.DataSource = rs
End If

rs.Close()
rs = Nothing
conn.Close()

How do I display all the rows and make the scroll bar work?
0
Comment
Question by:mph23
[X]
Welcome to Experts Exchange

Add your voice to the tech community where 5M+ people just like you are talking about what matters.

  • Help others & share knowledge
  • Earn cash & points
  • Learn & ask questions
  • 3
5 Comments
 
LVL 83

Expert Comment

by:CodeCruiser
ID: 37782920
Have you tried using a SqlCeDataAdapter to fill a DataTable and then use that as data source of the grid?
0
 

Author Comment

by:mph23
ID: 37783287
No, I didn't even know about them. I will try that - thanks for the tip!
0
 

Author Comment

by:mph23
ID: 37783669
I tried the following but it returns empty table:

        Dim cmd As New SqlCeCommand()
        Dim conn As New SqlCeConnection()
        Dim rs As SqlCeResultSet

        conn.ConnectionString = "Data Source = '\MyData.sdf'; mode=Exclusive;"
        conn.Open()

       cmd = conn.CreateCommand()
       cmd.CommandText = "SELECT * FROM tools"
       
       rs = cmd.ExecuteResultSet(ResultSetOptions.Scrollable Or ResultSetOptions.Updatable)

       If rs.HasRows = True Then
                Dim adp As New SqlCeDataAdapter(cmd)
                Dim ds As New System.Data.DataSet()

                adp.Fill(ds)
                Me.MyDataGrid.DataSource = ds
                MyDataGrid.Visible = True
                MyDataGrid.Refresh()
        End If
0
 
LVL 35

Accepted Solution

by:
Robert Schutt earned 500 total points
ID: 37786091
can you try:

Me.MyDataGrid.DataSource = ds.Tables(0)

Open in new window

0
 

Author Closing Comment

by:mph23
ID: 37854762
Thanks
0

Featured Post

Free Tool: SSL Checker

Scans your site and returns information about your SSL implementation and certificate. Helpful for debugging and validating your SSL configuration.

One of a set of tools we are providing to everyone as a way of saying thank you for being a part of the community.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

Suggested Solutions

Welcome my friends to the second instalment and follow-up to our Minify and Concatenate Your Scripts and Stylesheets (http://www.experts-exchange.com/Programming/Languages/.NET/ASP.NET/A_4334-Minify-and-Concatenate-Your-Scripts-and-Stylesheets.html)…
If you need to start windows update installation remotely or as a scheduled task you will find this very helpful.
In an interesting question (https://www.experts-exchange.com/questions/29008360/) here at Experts Exchange, a member asked how to split a single image into multiple images. The primary usage for this is to place many photographs on a flatbed scanner…

739 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question