私のコードは、例外を発生させません。例外は、「そのような表:TABLE_NAME」私はそれを解決しようと一日を過ごしたが、これまでのところ成功していないTABLE_NAME</p> </blockquote> <p>:</p> <blockquote> <p>はありません、このような表
SQLite3.exe
を使用してデータベースを作成しました。テーブルperson
を作成し、データを挿入します。私がテーブルperson
の内容を照会すると、私には肯定的な結果が示されます。
残念ながら、私は例外が発生したテーブルの内容を表示するには、このコードを使用する場合。
これはコードです:
procedure TForm1.connectButtonClick(Sender: TObject);
begin
// Set the path of your database file.
// Replace "full_path_to_your_database_file" with the absolute path
// to your SQLite database file.
SQLConnection1.Params.Add('Database=D:\testdb.db');
try
// Establish the connection.
SQLConnection1.Connected := true;
executeButton.Enabled := true;
outputMemo.Text := 'Connection established!';
except
on E: EDatabaseError do
ShowMessage('Exception raised with message' + E.Message);
end;
end;
procedure TForm1.executeButtonClick(Sender: TObject);
var
results: TDataSet;
query: String;
begin
outputMemo.Clear;
// A random query
query := 'SELECT * FROM person;';
try
// Execute the query on the database.
SQLConnection1.Execute(query, nil, results);
except
on E: Exception do
outputMemo.Text := 'Exception raised with message: ' + E.Message;
end;
// Show the results of the query in a TMemo control.
ShowSelectResults(results);
end;
procedure TForm3.ShowSelectResults(results: TDataSet);
var
names: TStringList;
i: Integer;
currentField: TField;
currentLine: string;
begin
if not results.IsEmpty then
begin
results.First;
names := TStringList.Create;
results.GetFieldNames(names);
while not results.Eof do
begin
currentLine := '';
for i := 0 to names.Count - 1 do
begin
currentField := results.FieldByName(names[i]);
currentLine := currentLine + ' ' + currentField.AsString;
end;
outputMemo.Lines.Add(currentLine);
results.Next;
end;
end;
end;
[メッセージで上昇SQLiteの例外:そのようなテーブル]の可能な重複(http://stackoverflow.com/questions/16585953/sqlite-exception -raised - メッセージ-NO-なテーブル付き) –
'ShowSelectResults(結果);' 'TForm1'のメンバーであるが、私はForm1.ShowSelectResults()'と思うTForm3.ShowSelectResults'あなたは '私たちを見る'別のコードウィッヒを持って、我々見ることができません !! –
@MartynA:メモリリーク: 'results'の代わりに' names:= TStringList.Create; 'を意味すると思います!! –