Ошибка SQL запроса
Вот такая ошибка
При выполнении SQL запроса к базе возникает ошибка
Вот текст процедуры при вызове которой ошибка
Код:
procedure TForm2.Button2Click(Sender: TObject);
begin
with form2.Query1 do begin
Close; // cae?uou oaee — ?acoeuoao auiieiaiey
SQL.Clear; // oaaeeou oaeno i?aauaouaai cai?ina
// caienuaaai iiaue cai?in a naienoai SQL
SQL.Add('insert into ":dasha:dasha.db" (Name,Familia,Ocenka)');
SQL.Add(' values ("vadim","test",5)');
Open; // aeoeaece?oai auiieiaiea cai?ina
end;
end;
begin
with form2.Query1 do begin
Close; // cae?uou oaee — ?acoeuoao auiieiaiey
SQL.Clear; // oaaeeou oaeno i?aauaouaai cai?ina
// caienuaaai iiaue cai?in a naienoai SQL
SQL.Add('insert into ":dasha:dasha.db" (Name,Familia,Ocenka)');
SQL.Add(' values ("vadim","test",5)');
Open; // aeoeaece?oai auiieiaiea cai?ina
end;
end;
А Вот полный текст
Код:
unit Unit2;
interface
uses
Windows, Messages, SysUtils, Variants, Classes, Graphics, Controls, Forms,
Dialogs, StdCtrls, ExtCtrls, ComCtrls, DB, DBTables;
type
TForm2 = class(TForm)
RadioGroup1: TRadioGroup;
Button1: TButton;
Image1: TImage;
Label1: TLabel;
Timer1: TTimer;
Label2: TLabel;
Button2: TButton;
Button3: TButton;
Query1: TQuery;
procedure FormShow(Sender: TObject);
procedure Button1Click(Sender: TObject);
procedure Timer1Timer(Sender: TObject);
procedure Button2Click(Sender: TObject);
procedure Button3Click(Sender: TObject);
private
{ Private declarations }
public
sh : boolean;
end;
q = record
qst : string;
v1, v2, v3 : string;
r : integer;
end;
var
Form2: TForm2;
f : text;
s, n, i : integer;
a: array[1..100] of q;
DateTimeB, DateTimeC: TDateTime;
implementation
uses unit1, Unit4, Unit5;
{$R *.dfm}
procedure TForm2.FormShow(Sender: TObject);
var p : string;
begin
s := 0;
n := 0;
i := 1;
assignfile(f, Form1.t);
reset(f);
while not eof(f) do
begin
n := n+1;
readln(f, a[n].qst);
readln(f, p);
readln(f, a[n].v1);
readln(f, a[n].v2);
readln(f, a[n].v3);
a[n].r := strtoint(p);
end;
closefile(f);
RadioGroup1.Caption := 'aa?eaiou ioaaoia';
Label2.Caption := 'Aii?in ?'+inttostr(i)+' '+a.qst;
RadioGroup1.Items.Strings[0] := a.v1;
RadioGroup1.Items.Strings[1] := a.v2;
RadioGroup1.Items.Strings[2] := a.v3;
Label1.Caption := '';
DateTimeB := GetTime;
end;
procedure TForm2.Button1Click(Sender: TObject);
begin
if RadioGroup1.ItemIndex >=0 then
begin
if RadioGroup1.ItemIndex+1 = a.r then
begin
s := s+1;
if sh then
begin
Image1.Visible := true;
Image1.Picture.LoadFromFile('right.bmp');
Image1.Refresh;
Sleep(1000);
Image1.Visible := false;
end;
end
else
begin
if sh then
begin
Image1.Visible := true;
Image1.Picture.LoadFromFile('wrong.bmp');
Image1.Refresh;
Sleep(1000);
Image1.Visible := false;
end;
end;
i := i+1;
RadioGroup1.ItemIndex := -1;
if i > n then
begin
with form2.Query1 do begin
Close; // cae?uou oaee — ?acoeuoao auiieiaiey
SQL.Clear; // oaaeeou oaeno i?aauaouaai cai?ina
// caienuaaai iiaue cai?in a naienoai SQL
SQL.Add('insert into ":dasha:dasha.db" (Name,Familia,Ocenka)');
SQL.Add(' values ("'+ namL +'","'+ famL +'",' + inttostr(s) + ')');
Open; // aeoeaece?oai auiieiaiea cai?ina
end;
ShowMessage('Eiiao, aao ?acoeuoao-'+inttostr(s));
Close;
end;
RadioGroup1.Caption := 'aa?eaiou ioaaoia';
Label2.Caption := 'Aii?in ?'+inttostr(i)+' '+a.qst;
RadioGroup1.Items.Strings[0] := a.v1;
RadioGroup1.Items.Strings[1] := a.v2;
RadioGroup1.Items.Strings[2] := a.v3;
end
else
ShowMessage('Au ia ioaaoeee!');
end;
procedure TForm2.Timer1Timer(Sender: TObject);
begin
DateTimeC := GetTime; //Oaeouaa a?aiy
// DateTimeC := DateTimeC - DateTimeB;// ec oaeouaai au?eoaai a?aiy ia?aea
Label1.Caption := TimeToStr(DateTimeC - DateTimeB)//I?aia?acoai a no?ieo
end;
procedure TForm2.Button2Click(Sender: TObject);
begin
with form2.Query1 do begin
Close; // cae?uou oaee — ?acoeuoao auiieiaiey
SQL.Clear; // oaaeeou oaeno i?aauaouaai cai?ina
// caienuaaai iiaue cai?in a naienoai SQL
SQL.Add('insert into ":dasha:dasha.db" (Name,Familia,Ocenka)');
SQL.Add(' values ("vadim","test",5)');
Open; // aeoeaece?oai auiieiaiea cai?ina
end;
end;
procedure TForm2.Button3Click(Sender: TObject);
begin
Form5.Show;
end;
end.
interface
uses
Windows, Messages, SysUtils, Variants, Classes, Graphics, Controls, Forms,
Dialogs, StdCtrls, ExtCtrls, ComCtrls, DB, DBTables;
type
TForm2 = class(TForm)
RadioGroup1: TRadioGroup;
Button1: TButton;
Image1: TImage;
Label1: TLabel;
Timer1: TTimer;
Label2: TLabel;
Button2: TButton;
Button3: TButton;
Query1: TQuery;
procedure FormShow(Sender: TObject);
procedure Button1Click(Sender: TObject);
procedure Timer1Timer(Sender: TObject);
procedure Button2Click(Sender: TObject);
procedure Button3Click(Sender: TObject);
private
{ Private declarations }
public
sh : boolean;
end;
q = record
qst : string;
v1, v2, v3 : string;
r : integer;
end;
var
Form2: TForm2;
f : text;
s, n, i : integer;
a: array[1..100] of q;
DateTimeB, DateTimeC: TDateTime;
implementation
uses unit1, Unit4, Unit5;
{$R *.dfm}
procedure TForm2.FormShow(Sender: TObject);
var p : string;
begin
s := 0;
n := 0;
i := 1;
assignfile(f, Form1.t);
reset(f);
while not eof(f) do
begin
n := n+1;
readln(f, a[n].qst);
readln(f, p);
readln(f, a[n].v1);
readln(f, a[n].v2);
readln(f, a[n].v3);
a[n].r := strtoint(p);
end;
closefile(f);
RadioGroup1.Caption := 'aa?eaiou ioaaoia';
Label2.Caption := 'Aii?in ?'+inttostr(i)+' '+a.qst;
RadioGroup1.Items.Strings[0] := a.v1;
RadioGroup1.Items.Strings[1] := a.v2;
RadioGroup1.Items.Strings[2] := a.v3;
Label1.Caption := '';
DateTimeB := GetTime;
end;
procedure TForm2.Button1Click(Sender: TObject);
begin
if RadioGroup1.ItemIndex >=0 then
begin
if RadioGroup1.ItemIndex+1 = a.r then
begin
s := s+1;
if sh then
begin
Image1.Visible := true;
Image1.Picture.LoadFromFile('right.bmp');
Image1.Refresh;
Sleep(1000);
Image1.Visible := false;
end;
end
else
begin
if sh then
begin
Image1.Visible := true;
Image1.Picture.LoadFromFile('wrong.bmp');
Image1.Refresh;
Sleep(1000);
Image1.Visible := false;
end;
end;
i := i+1;
RadioGroup1.ItemIndex := -1;
if i > n then
begin
with form2.Query1 do begin
Close; // cae?uou oaee — ?acoeuoao auiieiaiey
SQL.Clear; // oaaeeou oaeno i?aauaouaai cai?ina
// caienuaaai iiaue cai?in a naienoai SQL
SQL.Add('insert into ":dasha:dasha.db" (Name,Familia,Ocenka)');
SQL.Add(' values ("'+ namL +'","'+ famL +'",' + inttostr(s) + ')');
Open; // aeoeaece?oai auiieiaiea cai?ina
end;
ShowMessage('Eiiao, aao ?acoeuoao-'+inttostr(s));
Close;
end;
RadioGroup1.Caption := 'aa?eaiou ioaaoia';
Label2.Caption := 'Aii?in ?'+inttostr(i)+' '+a.qst;
RadioGroup1.Items.Strings[0] := a.v1;
RadioGroup1.Items.Strings[1] := a.v2;
RadioGroup1.Items.Strings[2] := a.v3;
end
else
ShowMessage('Au ia ioaaoeee!');
end;
procedure TForm2.Timer1Timer(Sender: TObject);
begin
DateTimeC := GetTime; //Oaeouaa a?aiy
// DateTimeC := DateTimeC - DateTimeB;// ec oaeouaai au?eoaai a?aiy ia?aea
Label1.Caption := TimeToStr(DateTimeC - DateTimeB)//I?aia?acoai a no?ieo
end;
procedure TForm2.Button2Click(Sender: TObject);
begin
with form2.Query1 do begin
Close; // cae?uou oaee — ?acoeuoao auiieiaiey
SQL.Clear; // oaaeeou oaeno i?aauaouaai cai?ina
// caienuaaai iiaue cai?in a naienoai SQL
SQL.Add('insert into ":dasha:dasha.db" (Name,Familia,Ocenka)');
SQL.Add(' values ("vadim","test",5)');
Open; // aeoeaece?oai auiieiaiea cai?ina
end;
end;
procedure TForm2.Button3Click(Sender: TObject);
begin
Form5.Show;
end;
end.
А вот ошибка на фото в прикреплённом файле
написано, что означчает эта ошибка. Ваш запрос insert возвращает данные? Нет. Тогда быстро меняем Open (открытие курсора, который собственно и не открывается) на ExecSQL, который тупо выполнит код вставки. И на будущее - сначала читайте, что делает метод, прежде ем вызывать его.
А что же вы хотели? Вам же четко и ясно