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
Click For Summary

Discussion Overview

The discussion revolves around how to display a SQL database, specifically using SQLite, as a table in a Win32 program. Participants explore various programming toolkits and methodologies for achieving this, touching on both technical implementation and the appropriateness of using SQL for smaller applications.

Discussion Character

  • Exploratory
  • Technical explanation
  • Debate/contested
  • Conceptual clarification

Main Points Raised

  • One participant inquires about displaying data from a local SQLite database in a Win32 program using either Dev-C++ or MSVS++.
  • Another participant questions the necessity of using SQL for a small basketball team, suggesting alternatives like plain text files or XML, and shares a PHP example of data retrieval.
  • A participant mentions that SQLite can handle data translation and expresses interest in displaying the data in a grid format, noting that a SELECT * query would return a char** type.
  • One reply emphasizes the importance of the GUI toolkit in determining how to input data into a table, providing a code snippet for filling a table in Qt.
  • A participant expresses confusion about which toolkit to use, stating a preference against Qt and seeking recommendations for other options.
  • Another participant lists various toolkits, favoring Qt and GTK+, while noting that Qt is a commercial product and GTK+ is free software.

Areas of Agreement / Disagreement

Participants express differing opinions on the appropriateness of using SQL for small projects, with some advocating for SQL and others suggesting simpler alternatives. There is also no consensus on which GUI toolkit to use, as preferences vary among participants.

Contextual Notes

Participants have not resolved the question of which toolkit is best suited for the task, and there are unresolved preferences regarding the use of SQL versus simpler data storage methods.

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
 

Similar threads

Replies
6
Views
2K
Replies
11
Views
2K
  • · Replies 1 ·
Replies
1
Views
2K
  • · Replies 8 ·
Replies
8
Views
3K
  • · Replies 1 ·
Replies
1
Views
2K
Replies
7
Views
3K
  • · Replies 5 ·
Replies
5
Views
3K
  • · Replies 2 ·
Replies
2
Views
2K
  • · Replies 50 ·
2
Replies
50
Views
10K
  • · Replies 5 ·
Replies
5
Views
2K