all groups > dotnet compact framework > october 2005 >
You're in the

dotnet compact framework

group:

Problem with SQLDataAdapter.Fill and datagrid.setdatabindings


Problem with SQLDataAdapter.Fill and datagrid.setdatabindings Ralf Christoff
10/31/2005 11:40:27 PM
dotnet compact framework:
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

RE: Problem with SQLDataAdapter.Fill and datagrid.setdatabindings John Holmer
11/1/2005 9:42:02 AM
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

[quoted text, click to view]
AddThis Social Bookmark Button