[2 days left] What’s wrong with your cloud strategy? Learn why multicloud solutions matter with Nimble Storage.Register Now

x
?
Solved

Datagrid not displaying all rows

Posted on 2012-03-29
5
Medium Priority
?
319 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 1500 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

What does it mean to be "Always On"?

Is your cloud always on? With an Always On cloud you won't have to worry about downtime for maintenance or software application code updates, ensuring that your bottom line isn't affected.

Question has a verified solution.

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

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.
Want to learn how to record your desktop screen without having to use an outside camera. Click on this video and learn how to use the cool google extension called "Screencastify"! Step 1: Open a new google tab Step 2: Go to the left hand upper corn…
Are you ready to place your question in front of subject-matter experts for more timely responses? With the release of Priority Question, Premium Members, Team Accounts and Qualified Experts can now identify the emergent level of their issue, signal…

656 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