Здравствуйте! При запуске программы с базой данных вылетает ошибка
http://www.imagepost.ru/?v=855/1.JPG
Код здесь:
C++ |
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
| procedure TFormMain.BitBtn1Click(Sender: TObject);
var s:string;
begin
if (InputQuery('Ввод группы', 'Группа:', s)) then
begin
with dm.q do
begin
Active := false;
SQL.Clear;
SQL.Add('INSERT INTO GROUPS(NAME_GROUPS) VALUES(');
SQL.Add(QuotedStr(s) + ')');
ExecSQL;
end;
with dm.SimpleDSGroups do
begin
Active := false;
DataSet.Active := false;
DataSet.Active := true;
Active := true;
Locate('NAME_GROUPS', s, [loCaseInsensitive]);
end;
BitBtnEnabled(0);
end;
end;
procedure TFormMain.BitBtn2Click(Sender: TObject);
var s:string;
begin
s := InputBox('Редактирование группы', 'Группа:', dm.SimpleDSGroups.FieldByName('NAME_GROUPS').AsString);
if (s <> '') then
begin
with dm.q do
begin
Active := false;
SQL.Clear;
SQL.Add('UPDATE GROUPS SET ');
SQL.Add(' NAME_GROUPS= ' + QuotedStr(s));
// Эту строку выделил пользователь
SQL.Add(' WHERE ID_GROUPS=' + dm.SimpleDSGroups.FieldByName('ID_GROUPS').AsString);
ExecSQL;
end;
with dm.SimpleDSGroups do
begin
Active := false;
DataSet.Active := false;
DataSet.Active := true;
Active := true;
Locate('NAME_GROUPS', s, [loCaseInsensitive]);
end;
end;
end;
procedure TFormMain.BitBtn3Click(Sender: TObject);
begin
if Application.MessageBox('Вы действительно хотите удалить выделенную запись?',
'Внимание!!!', MB_YESNO + MB_ICONWARNING) = ID_YES then
begin
with dm.q do
begin
Active := false;
SQL.Clear;
SQL.Add('DELETE FROM STUDENTS ');
SQL.Add(' WHERE ID_GROUPS=' + dm.SimpleDSGroups.FieldByName('ID_GROUPS').AsString);
ExecSQL;
Active := false;
SQL.Clear;
SQL.Add('DELETE FROM GROUPS ');
SQL.Add(' WHERE ID_GROUPS=' + dm.SimpleDSGroups.FieldByName('ID_GROUPS').AsString);
ExecSQL;
end;
with dm.SimpleDSGroups do
begin
Active := false;
DataSet.Active := false;
DataSet.Active := true;
Active := true;
end;
BitBtnEnabled(0);
end;
end;
procedure TFormMain.BitBtn7Click(Sender: TObject);
begin
close;
end;
procedure TFormMain.BitBtnEnabled(i: integer);
begin
case i of
0:
begin
if dm.SimpleDSGroups.RecordCount = 0 then
begin
BitBtn2.Enabled := false;
BitBtn3.Enabled := false;
end
else
begin
BitBtn2.Enabled := true;
BitBtn3.Enabled := true;
end;
end;
1:
begin
if dm.SimpleDSGroups.RecordCount = 0 then
BitBtn4.Enabled := false
else
BitBtn4.Enabled := true;
if dm.SimpleDSStudents.RecordCount = 0 then
begin
BitBtn5.Enabled := false;
BitBtn6.Enabled := false;
end
else
begin
BitBtn5.Enabled := true;
BitBtn6.Enabled := true;
end;
end;
end;
end;
procedure TFormMain.FormActivate(Sender: TObject);
begin
PageControl1.ActivePage := TabSheet1;
dm.SQLConnection1.Connected := false;
dm.SQLConnection1.Params.Values['database'] := ExtractFileDir(ParamStr(0)) + '\bd.fdb';
dm.SQLConnection1.Connected := true;
dm.SimpleDSGroups.Active := false;
dm.SimpleDSGroups.DataSet.Active := false;
dm.SimpleDSGroups.DataSet.CommandText := 'SELECT * FROM GROUPS';
dm.SimpleDSGroups.DataSet.Active := true;
dm.SimpleDSGroups.Active := true;
BitBtnEnabled(0);
end;
procedure TFormMain.PageControl1Change(Sender: TObject);
begin
if PageControl1.ActivePage = TabSheet2 then
begin
BitBtnEnabled(1);
if dm.SimpleDSGroups.RecordCount = 0 then
exit;
with dm.SimpleDSStudents do
begin
Active := false;
DataSet.Active := false;
DataSet.CommandText := 'SELECT * FROM STUDENTS WHERE ID_GROUPS=' +
dm.SimpleDSGroups.FieldByName('ID_GROUPS').AsString;
DataSet.Active := true;
Active := true;
end;
end;
end;
end. |
|
Не подскажете как можно это исправить. Заранее благодарю.