I have tried to post this question several times but the I kept getting a 'Blocked' message. I have added the underscore character '_' at several obvious points in the message to try and avoid the 'Blocked' message. There is nothing in the post that appears malicious to me. If anyone sees anything in the post that is malicious, please let me know and I will delete the post. Anyway here is the original post with the obvious underscore characters added:
////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
I am writing a program that examines generic SQLite databases. I have an OnTitleClick event that toggles between sorting the field ascending or descending. My problem is that when I click on the 'MemberInfoID' column title, the address of the column changes, which leads to errors in the program. Clicking on any other column works as expected. I looked at the data in the 'MemberInfoID' field with sqlite3.exe and it all looks OK.
To aid in troubleshooting, I added the Edit1 TEdit control to watch the changes in the 'Column' address.
I wrote another small test program to troubleshoot the problem and the problem still occurs.
Note: the problem also occurs in other SQLite tables in the database. Fields that exhibit the problem, always exhibit the problem. Fields that do not exhibit the problem never exhibit the problem, so it is not random. The problem also seems to be independant of data type. Some fields with integer types and some fields with varchar types exhibit the problem, but not all fields with those fields exhibit the problem.
The following controls are in the main form:
DBGrid
TEdit
The following controls are in the DataSource file:
FDPhysSQLiteDriverLink1
FDConnection
FDQuery
DataSource
Other than setting the FDConnection driver and database, adding an SQL to the FDQuery, and linking the DBGrid, DataSource, and DataSet, all other properties are the default values.
This code below is all of the code that I have written. The rest is generated by C++ Berlin 10.2.
void __fastcall TForm2::DBGridDataTitleClick(TColumn *Column) {
Edit1->Text = int(Column);
AnsiString ColumnFieldName = Column->FieldName;
if ((ColumnToSort != NULL) && (ColumnToSort == Column))
SortAsc = !SortAsc;
else
SortAsc = true;
UnicodeString SQLString = "SELECT * From SSAttendance";
SQLString += " ORDER BY ";
SQLString += ColumnFieldName;
if (!SortAsc)
SQLString += " DESC";
/*
if I return here, the column address does not get overwritten. If I comment this line out, the 'MemberInfoID'column is overwritten in the following code:
*/
return;
DataModule3->FDQueryData->Close();
DataModule3->FDQueryData->SQL->Text = SQLString;
DataModule3->FDQueryData->Open();
ColumnToSort = Column;
}
Why does the code to sort the database overwrite the 'Column' address when the 'MemberInfoID' column title is clicked in this table?
I know the column address should change the first time the column title is clicked, but not on subsequent clicks.
Regards...
Earl Staley