How to Display a SQL Database as a Table in a Win32 Program?

  • Thread starter Thread starter ponjavic
  • Start date Start date
  • Tags Tags
    Sql Table
AI Thread Summary
When displaying a SQLite database in a Win32 program using C++ (either Dev-C++ or MSVS++), the choice of GUI toolkit is crucial as it influences how data is presented in a table format. While SQL may seem excessive for small applications, such as managing a basketball team, it offers structured data handling that plain text files or XML cannot match. The process of retrieving data from SQLite involves executing SQL queries and iterating through the results, similar to PHP's handling of database queries. For GUI implementation, familiarity with object-oriented programming is essential. If not using Qt, which is often preferred for its capabilities but is a commercial product, GTK+ is a recommended alternative as it is open-source. Other toolkits exist, but Qt and GTK+ are highlighted as the most effective for creating grid tables to display database content.
ponjavic
Messages
221
Reaction score
0
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++?
 
Computer science news on Phys.org
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:

Code:
$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;
}
 
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
 
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:

Code:
 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.
 
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?
 
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
 
Sorry if 'Profile Badge' is not the correct term. I have an MS 365 subscription and I've noticed on my Word documents the small circle with my initials in it is sometimes different in colour document to document (it's the circle at the top right of the doc, that, when you hover over it it tells you you're signed in; if you click on it you get a bit more info). Last night I had four docs with a red circle, one with blue. When I closed the blue and opened it again it was red. Today I have 3...
Thread 'ChatGPT Examples, Good and Bad'
I've been experimenting with ChatGPT. Some results are good, some very very bad. I think examples can help expose the properties of this AI. Maybe you can post some of your favorite examples and tell us what they reveal about the properties of this AI. (I had problems with copy/paste of text and formatting, so I'm posting my examples as screen shots. That is a promising start. :smile: But then I provided values V=1, R1=1, R2=2, R3=3 and asked for the value of I. At first, it said...
Back
Top