Solved

Datagrid not displaying all rows

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

Threat Intelligence Starter Resources

Integrating threat intelligence can be challenging, and not all companies are ready. These resources can help you build awareness and prepare for defense.

Join & Write a Comment

Creating an analog clock UserControl seems fairly straight forward.  It is, after all, essentially just a circle with several lines in it!  Two common approaches for rendering an analog clock typically involve either manually calculating points with…
Real-time is more about the business, not the technology. In day-to-day life, to make real-time decisions like buying or investing, business needs the latest information(e.g. Gold Rate/Stock Rate). Unlike traditional days, you need not wait for a fe…
Access reports are powerful and flexible. Learn how to create a query and then a grouped report using the wizard. Modify the report design after the wizard is done to make it look better. There will be another video to explain how to put the final p…
This demo shows you how to set up the containerized NetScaler CPX with NetScaler Management and Analytics System in a non-routable Mesos/Marathon environment for use with Micro-Services applications.

707 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

Need Help in Real-Time?

Connect with top rated Experts

12 Experts available now in Live!

Get 1:1 Help Now