PDA

View Full Version : SQL report help



markstaylor
03-07-2010, 01:40 PM
Need help with this code.

I run a query based on what the user selected and pull all data that matches the query DECRYPTIT then send to a grid object. It's not working correct.

I get random results. If i select recordid and name only the name is displayed but in the record id column and nothing is in the name field.

PLEASE HELP.



if sqlString ~= "" then
tbResults = SQLite.QueryToTable(db, sqlString);

TextFile.WriteFromString("AutoPlay\\Docs\\report.csv", headerString .."\r\n", false);

for nRow =1, tbResults.Rows do

sRowData = "";

for nCol = 1, tbResults.Columns do

sRowData = Crypto.BlowfishDecryptString(tbResults.Data[nRow][tbResults.ColumnNames[nCol]],"passoword")
sRowData= String.Replace(sRowData, "\r\n", " ");
sRowData= sRowData ..",";
end

TextFile.WriteFromString("AutoPlay\\Docs\\report.csv", sRowData .."\r\n", true);

end
DialogEx.Show("ReportResults", true, nil, nil);
end

Dermot
03-07-2010, 01:47 PM
With your code sRowData will only ever contain data from one column. Try this


sRowData = sRowData..Crypto.BlowfishDecryptString(tbResults.D ata[nRow][tbResults.ColumnNames[nCol]],"passoword")
sRowData = String.Replace(sRowData, "\r\n", " ");
sRowData= sRowData ..",";

Why not just put the data straight into the grid instead of writing out to a file?

markstaylor
03-07-2010, 02:42 PM
That did work, thanks BUT the record ID is blank.

I couldn't get the data to the grid with the header without writing it to a csv file first. Man if you can help with that to that would be greatly appreciated.

Dermot
03-08-2010, 02:06 AM
Without knowing what the database looks like, its hard to know. Maybe post your app or at least a scaled down version.

RizlaUK
03-08-2010, 03:32 AM
I couldn't get the data to the grid with the header without writing it to a csv file first. Man if you can help with that to that would be greatly appreciated.

look at the below example, it contains some functions for loading sqlite directly into the grid :yes

http://www.indigorose.com/forums/showpost.php?p=125215&postcount=7