Problem with SQLDataAdapter.Fill and datagrid.setdatabindings

R

Ralf Christoff

Hi,
the following Code works on a Windows-Apllication but not in a PPC Project:
adapter.fill and datagrid.setdataBinding is not supportet at
compact-Framework?
Can anyone tell me an other way to bind my Resultset to an Datagrid?

SqlConnection conn = new SqlConnection(SQLKonfig.SQLCon);
ds = new DataSet();
SqlCommand cmd = new SqlCommand(SQL, conn);
SqlDataAdapter adapter = new SqlDataAdapter(cmd);
conn.Open();
adapter.Fill(ds); <= here is the 1.problem
conn.Close();

if(ds.Tables.Count>0)
{
dg_Query.SetDataBinding= (ds,"Table"); <= here is the 2.
problem
}
if(ds.Tables.Count>1)
{
dg_Query1.SetDataBinding(ds,"Table1"); <= here is the 2.
problem,too ;)
}

thanx for any help,
and sorry for my bad english ;)
Ralf
 
G

Guest

Ralf,

We are using SQL Server CE, and we use code that is very similar to the code
that follows:

DataTable dt = new DataTable();
SqlCeCommand sqlCeCommand = sqlCeConnection.CreateCommand();
sqlCeCommand.CommandText = "Select * from blah";
SqlCeDataAdapter SqlCeDA = new SqlCeDataAdapter(sqlCeCommand);
SqlCeDA.Fill(dt);
SqlCeDA.Dispose();
sqlCeCommand.Dispose();
yourDataGrid.DataSource = dt;

HTH,
John
 

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