Solved

Datagrid not displaying all rows

Posted on 2012-03-29
5
317 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

SharePoint Admin?

Enable Your Employees To Focus On The Core With Intuitive Onscreen Guidance That is With You At The Moment of Need.

Question has a verified solution.

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

This document covers how to connect to SQL Server and browse its contents.  It is meant for those new to Visual Studio and/or working with Microsoft SQL Server.  It is not a guide to building SQL Server database connections in your code.  This is mo…
If you need to start windows update installation remotely or as a scheduled task you will find this very helpful.
In this video we outline the Physical Segments view of NetCrunch network monitor. By following this brief how-to video, you will be able to learn how NetCrunch visualizes your network, how granular is the information collected, as well as where to f…
Michael from AdRem Software explains how to view the most utilized and worst performing nodes in your network, by accessing the Top Charts view in NetCrunch network monitor (https://www.adremsoft.com/). Top Charts is a view in which you can set seve…

724 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