setting schema of dataset?

  • Thread starter Thread starter Michael Appelmans
  • Start date Start date
M

Michael Appelmans

I created a windows Form using Visual Studio and was able to display
data in a DataGrid using a SQLDataAdapter. But now I need to be able to
issue different select commands to retrieve different columns but the
datagrid still shows the original columns.

My current code looks something like this:
// two sql commands, only difference is column selection
this.sqlCmd1.CommandText = "SELECT uid, myColumn1 FROM
tristore.dbo.Products ORDER BY myColumn1";
this.sqlCmd1.Connection = this.sqlConnection1;

this.sqlCmd2.CommandText = "SELECT uid, myColumn2 FROM
tristore.dbo.Products ORDER BY myColumn2";
this.sqlCmd2.Connection = this.sqlConnection1;


sqlDataAdapter1.SelectCommand = sqlCmd1;
sqlDataAdapter1.FillSchema(dataSet1,SchemaType.Source);
sqlDataAdapter1.Fill(dataSet1);

But I still wind up with the old schema I had defined in the
SQLDataAdapter properties which displays both mycol1 and mycol2.

Any suggestions would be appreciated.

Michael
 
Michael said:
I created a windows Form using Visual Studio and was able to display
data in a DataGrid using a SQLDataAdapter. But now I need to be able to
issue different select commands to retrieve different columns but the
datagrid still shows the original columns.

My current code looks something like this:
// two sql commands, only difference is column selection
this.sqlCmd1.CommandText = "SELECT uid, myColumn1 FROM
tristore.dbo.Products ORDER BY myColumn1";
this.sqlCmd1.Connection = this.sqlConnection1;

this.sqlCmd2.CommandText = "SELECT uid, myColumn2 FROM
tristore.dbo.Products ORDER BY myColumn2";
this.sqlCmd2.Connection = this.sqlConnection1;


sqlDataAdapter1.SelectCommand = sqlCmd1;
sqlDataAdapter1.FillSchema(dataSet1,SchemaType.Source);
sqlDataAdapter1.Fill(dataSet1);

But I still wind up with the old schema I had defined in the
SQLDataAdapter properties which displays both mycol1 and mycol2.

Any suggestions would be appreciated.

Michael
I am sure that you have thought that some sort of cache is getting in the
way?. I am thinking of the Application cache.
 
Back
Top