PDA

View Full Version : Displaying SQL in a table


ponjavic
Nov1-04, 07:38 AM
Let's say I'm communicating with a SQL (local) database using sqlite. How would i go about displaying this database as a table in a win32 program using either dev-c++ or MSVS++?

dduardo
Nov1-04, 11:23 AM
Don't you think SQL is overkill for a small basketball team? Why don't you just use a plain text file or xml? If you go the SQL route I don't think you'll ever finish your program.

From my experience with SQL and PHP when you SELECT somthing you'll get some encoded data that you can iterate through. A PHP Example:


$results = mysql_query('SELECT name FROM team');
while( $name = mysql_fetch_assoc($results) ) { // mysql_fetch_assoc gets the next chunk of data from $results
echo $name;
}

ponjavic
Nov1-04, 01:17 PM
seems as though sqlite can do the translation, I'm just wondering how to put it in some kind of grid table in a comfortable way
for example SELECT * would return char** using sqlite

dduardo
Nov1-04, 02:32 PM
Your really confused aren't you? The gui toolkit you use will dictate how you enter information into a table. This isn't basic C++ we are talking about here. You really have to be confortable with object oriented programming. For example if you use QT this is how you would enter a value into a cell:


for ( int row = 0; row < table->numRows(); row++ ) {
for ( int col = 0; col < table->numCols(); col++ ) {
table->setItem( row, col,
new QTableItem( table, QTableItem::WhenCurrent, QString::number( row * col ) ) );
}
}


The code above goes through the whole table and fills in each cell with its repected col * row value. Row 0 Col 0 would have a 0, Row 1 Col 5 would have a 5, Row 2 Col 10 would have a 20, etc.

ponjavic
Nov2-04, 01:29 PM
I am confused about which toolkit to use. We wen't over this before, I am not going to use Qt so what other either toolkits or grid tables would you recommend?

chroot
Nov2-04, 02:19 PM
There are a bunch of toolkits. The best ones, IMO, are Qt and GTK+. Qt is generally regarded as being superior, but it's a commerical product. GTK+ is free software.

- Warren