Dataset question.

  • Thread starter Thread starter objectref
  • Start date Start date
O

objectref

hi to all,

let's say i have the following code:

SqlDataAdapter da = new SqlDataAdapter(cmd.CommandText, cnn);
DataSet ds = new DataSet("ds");
TestData.DataSource = ds;
da.Fill(ds);


the abvoe code is working and fetch the data in a datagrid but it displays a
plus sign on the upper left
and use have to click this plus sign to see the data loaded in the datagrid.

Is there a way to prevent this ? I mean, when the code runs, i want the
datagrid to be filled with data.
It is something reletive to the datagrid.DataMember but i could not find
what exatly is...

Any help ?

objectref
 
Objectref

When you have only one table, than does this in the most easy way fits your
problem.
\\\
TestData.DataSource = ds.tables[0];
///
I hope this helps?

Cor
 
Cor Ligthert said:
Objectref

When you have only one table, than does this in the most easy way fits
your problem.
\\\
TestData.DataSource = ds.tables[0];
///
I hope this helps?

Cor



thanks for the reply. No, that cannot solve the problem.
I tried for a while and i found that if i write is as like this, it works:

SqlDataAdapter da = new SqlDataAdapter(cmd);
DataSet ds = new DataSet();
da.Fill(ds, "MyTable");
TestData.DataSource = ds;
TestData.DataMember = "MyTable";


Anyway, thanks again!
 
Objectref,

Strange because the code you are using now, is exactly the same as the
sample I gave you.
(however there was an obvious typo in it, I used a lower case t for tables
where it had to be a T)

I told you that I showed you the most easy way with a little bit more
characters is this.
\\\
TestData.DataSource = ds.Tables["mytable"];
///

:-)

Cor
 
Back
Top