SqlCeCommand not populating when ExecuteResultSet called during form_load

S

SarahP

Hello,

I am connecting to an SQL CE DB during the form load. If the following
code executes after the form is loaded from, a button click let's say,
everything is fine and the dataGrid populates as expected. However, if
I call the exact same code after the connection to the database, in the
form load, the result set and consequently the dataGrid are empty. The
column names are present, so it is connected to the database, and
finding the appropriate table, but for some reason it thinks there are
no records. Can anyone help?

The code is: (I'm writing in C# by the way): (and also conn = the
SqlCeConnection)

DataGrid1.DataSource = new SqlCeCommand("select Table2.ID, Table1.DESCR
from Table2 join Table1 on Table2.ID1 = Table1.ID",
conn).ExecuteResultSet(ResultSetOptions.Insensitive |
ResultSetOptions.Scrollable);

To repeat, there are results when done on a button click, and an empty
table if called during the form load, after the Db connection.
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Top