This is my first attempt at SQLCE and I am having an issue that I can't figure out. If I close the connection in the finally statement as shown below I only get the first record from the database. When I uncomment it I get both records. What am I doing wrong?
This is my code:
VB Code:
' Dim con As SqlCeConnection = Nothing Try Dim dir As String = Path.GetDirectoryName( _ Reflection.Assembly.GetExecutingAssembly().GetName().CodeBase) con = New SqlCeConnection("Data Source = '" & dir & "\RouteDB.sdf'") con.Open() Dim cmd As SqlCeCommand = New SqlCeCommand( _ "SELECT RouteID " & _ ", Name FROM Routes " & _ "Where IsDeleted = 0", con) cmd.CommandType = CommandType.Text Dim resultSet As SqlCeResultSet = _ cmd.ExecuteResultSet(ResultSetOptions.Scrollable) dgRoutes.DataSource = resultSet Catch ex As Exception MessageBox.Show(ex.Message.ToString) Finally 'con.Close() ' If I uncomment the close I only get the first record ' in the database. If I comment it out as is here ' both the records in the database show up. End Try


Reply With Quote


