> >Subject: Re: [sqlite] Suppressing column (field) headers? > From: [EMAIL PROTECTED] > Date: Mon, 22 Nov 2004 10:23:37 +1000 > To: [EMAIL PROTECTED]
>[EMAIL PROTECTED] >21/11/2004 04:56 PM >Please respond to sqlite-users > > > To: [EMAIL PROTECTED] > cc: > Subject: [sqlite] Suppressing column (field) headers? > > > >> 1. How can I get the dll to return JUST the desired data? >> When I send the following SQL, for example, >> select colEntry from tblEntry where colNum = 3 >> the textbox shows >> colEntry >> "The text in the column." >> <newline> > >This is being done by your delphi wrapper. I beat around doing traces until I began to get that picture. The code is doing things with TStrings and TSringlists. >Please consult its documentation. I wish. Heh. >The "C" interface of sqlite (for both 2.8 series and 3.0 >series) returns the column names and column values separately, and doesn't >return any extra "quote" characters. Makes sense. >Clay Dowling wrote: >> You can get just the data that you want by using the prepared statements >> feature of the 3.0.x dll. It sounds like you're using the table output >> method for getting your results. This is fine, but it means that you >need >> it ignore the first row of data, which in the table interface is the >> column labels. > >This statement makes you sound like you're taking crazy pills, Clay >(prepared statements and non-prepared statements aren't functionally >different in sqlite)... but I'm interested to know if you have a grain of >truth hidden in there. Are you familiar with the delphi wrapper Mswarm is >using? Which delphi wrapper are you using, Mswarm? It says: "Simple class interface for SQLite. Hacked in by Ben Hochstrasser ([EMAIL PROTECTED]) Thanks to Roger Reghin ([EMAIL PROTECTED]) for his idea to ValueList." >What does the code that issues your query look like? Benjamin, so far as I can tell, the relevant code is as follows: fTable: TStrings; fLstName: TStringList; fLstVal: TStringList; SQLite_Exec: function(db: Pointer; SQLStatement: PChar; CallbackPtr: Pointer; Sender: TObject; var ErrMsg: PChar): integer; cdecl; function ExecCallback(Sender: TObject; Columns: Integer; ColumnValues: Pointer; ColumnNames: Pointer): integer; cdecl; var PVal, PName: ^PChar; n: integer; sVal, sName: String; begin Result := 0; with Sender as TSQLite do begin if (Assigned(fOnData) or Assigned(fTable)) then begin fLstName.Clear; fLstVal.Clear; if Columns > 0 then begin PName := ColumnNames; PVal := ColumnValues; for n := 0 to Columns - 1 do begin fLstName.Append(PName^); fLstVal.Append(PVal^); inc(PName); inc(PVal); end; end; sVal := fLstVal.CommaText; sName := fLstName.CommaText; if Assigned(fOnData) then fOnData(Sender, Columns, sName, sVal); if Assigned(fTable) then begin if fTable.Count = 0 then fTable.Append(sName); fTable.Append(sVal); end; end; end; end; function TSQLite.Query(Sql: String; Table: TStrings = nil): boolean; begin fError := SQLITE_ERROR; if fIsOpen then begin fPMsg := nil; fBusy := True; fTable := Table; if fTable <> nil then fTable.Clear; fError := SQLite_Exec(fSQLite, PChar(Sql), @ExecCallback, Self, fPMsg); SQLite_FreeMem(fPMsg); fChangeCount := SQLite_Changes(fSQLite); fTable := nil; fBusy := False; if Assigned(fOnQueryComplete) then fOnQueryComplete(Self); end; fMsg := ErrorMessage(fError); Result := (fError <> SQLITE_OK); end; I haven't used TStrings much, but I'm guessing that appending to TStrings creates the newlines, and that the .commatext method creates the commas in the TStringlists. I still can't figure out which code would add the "double quote" marks around returned text, though, if the DLL doesn't return a string that way. I've search the code for the " mark and the #value, but nothing turns up. Thanks