Click to See Complete Forum and Search --> : database driven gui layout


paulcsf
January 11th, 2004, 10:56 AM
Hello All,

I am trying to build an app that uses a SQL database for the layout of the gui. The reason being that the functionallity of the gui will always be the same, but will go to many different customers that want their own layout.

I have figured out how to get datasets and bind them to datagrids, but does anybody know how to easily get individual elements out of the database?

Such as I have a record with many of the properties of a button. It's text, location, size, etc. I can't figure out how to get those values out of the database and use them for the button initialization.

Thanks in advance,

Paul

paulcsf
January 24th, 2004, 07:08 PM
Well, I figured out the answer to my question, just use the column name as the index into the array Item, which is a member of a datarow. The column names are automatically set by the data adapter.

Hope this helps somebody else.


//After a database connection has been opened,
//create a dataset, and a data adapter, then fill the dataset
//with information gained using the particular SQL command.
DataSet * myDataSet = new DataSet();
SqlDataAdapter * mySqlDataAdapter = new SqlDataAdapter("select * from nav",sql_Inco);
mySqlDataAdapter->Fill(myDataSet,"nav");

//loop through the all of the rows in the table in the dataset.
for (int i=0;i<myDataSet->Tables->Item["nav"]->Rows->Count; i++)
{
//create a datarow with one row from a table in the
//dataset.
DataRow * row = myDataSet->Tables->Item["nav"]->Rows->Item[i];
//now store the value into some variable.
//the column name is just the text in the Item[] index.
some_int_var=*static_cast<__box int*>(row->Item["page"]);
...
...
}