
15.03.2009, 15:10
|
 |
Гуру
|
|
Регистрация: 09.03.2009
Адрес: На курорте, из окна вижу теплое Баренцево море. Бррр.
Сообщения: 4,723
Репутация: 52347
|
|
Скорее всего ошибка в передаваемых данных.
Вот рабочий примерчик:
Код:
unit Unit1;
interface
uses
Windows, Messages, SysUtils, Variants, Classes, Graphics, Controls, Forms,
Dialogs, DB, ADODB, StdCtrls, Grids, DBGrids;
type
TForm1 = class(TForm)
Edit1: TEdit;
Edit2: TEdit;
DBGrid1: TDBGrid;
Label1: TLabel;
Label2: TLabel;
dsQuery: TDataSource;
Query: TADOQuery;
AppDB: TADOConnection;
Queryid: TAutoIncField;
QueryПреподаватель: TWideStringField;
QueryДисциплина1: TWideStringField;
QueryДисциплина2: TWideStringField;
QueryДисциплина3: TWideStringField;
Edit3: TEdit;
Label3: TLabel;
procedure FormCreate(Sender: TObject);
procedure EditChange(Sender: TObject);
end;
var
Form1: TForm1;
implementation
{$R *.dfm}
procedure Tform1.EditChange(Sender: TObject);
begin
Query.Close;
Query.SQL.Text := 'select * from Исполнители where [Преподаватель] like :Value1 and [Дисциплина №1] like :Value2 and [Дисциплина №2] like :Value3';
Query.Parameters.ParamValues['Value1'] := Edit3.Text + '%';
Query.Parameters.ParamValues['Value2'] := Edit1.Text + '%';
Query.Parameters.ParamValues['Value3'] := Edit2.Text + '%';
Query.Open;
end;
procedure TForm1.FormCreate(Sender: TObject);
begin
AppDB.Open;
EditChange(Sender);
end;
end.
object Form1: TForm1
Left = 0
Top = 0
Caption = 'Form1'
ClientHeight = 302
ClientWidth = 635
Color = clBtnFace
Font.Charset = DEFAULT_CHARSET
Font.Color = clWindowText
Font.Height = -11
Font.Name = 'Tahoma'
Font.Style = []
OldCreateOrder = False
OnCreate = FormCreate
PixelsPerInch = 96
TextHeight = 13
object Label1: TLabel
Left = 201
Top = 33
Width = 67
Height = 13
Caption = #1044#1080#1089#1094#1080#1087#1083#1080#1085#1072'1'
end
object Label2: TLabel
Left = 325
Top = 33
Width = 67
Height = 13
Caption = #1044#1080#1089#1094#1080#1087#1083#1080#1085#1072'2'
end
object Label3: TLabel
Left = 88
Top = 33
Width = 80
Height = 13
Caption = #1055#1088#1077#1087#1086#1076#1072#1074#1072#1090#1077#1083#1100
end
object Edit1: TEdit
Left = 201
Top = 48
Width = 118
Height = 21
TabOrder = 1
OnChange = EditChange
end
object Edit2: TEdit
Left = 325
Top = 48
Width = 121
Height = 21
TabOrder = 2
OnChange = EditChange
end
object DBGrid1: TDBGrid
Left = 8
Top = 75
Width = 619
Height = 120
DataSource = dsQuery
TabOrder = 3
TitleFont.Charset = DEFAULT_CHARSET
TitleFont.Color = clWindowText
TitleFont.Height = -11
TitleFont.Name = 'Tahoma'
TitleFont.Style = []
end
object Edit3: TEdit
Left = 88
Top = 48
Width = 112
Height = 21
TabOrder = 0
OnChange = EditChange
end
object dsQuery: TDataSource
DataSet = Query
Left = 528
Top = 192
end
object Query: TADOQuery
Active = True
Connection = AppDB
CursorType = ctStatic
Parameters = <>
SQL.Strings = (
'select * from '#1048#1089#1087#1086#1083#1085#1080#1090#1077#1083#1080)
Left = 528
Top = 144
object Queryid: TAutoIncField
DisplayWidth = 12
FieldName = 'id'
ReadOnly = True
end
object QueryПреподаватель: TWideStringField
DisplayWidth = 23
FieldName = #1055#1088#1077#1087#1086#1076#1072#1074#1072#1090#1077#1083#1100
Size = 255
end
object QueryДисциплина1: TWideStringField
DisplayWidth = 23
FieldName = #1044#1080#1089#1094#1080#1087#1083#1080#1085#1072' '#8470'1'
Size = 255
end
object QueryДисциплина2: TWideStringField
DisplayWidth = 24
FieldName = #1044#1080#1089#1094#1080#1087#1083#1080#1085#1072' '#8470'2'
Size = 255
end
object QueryДисциплина3: TWideStringField
DisplayWidth = 29
FieldName = #1044#1080#1089#1094#1080#1087#1083#1080#1085#1072' '#8470'3'
Size = 255
end
end
object AppDB: TADOConnection
Connected = True
ConnectionString =
'Provider=Microsoft.Jet.OLEDB.4.0;Data Source=C:\Users\'#1061#1086#1079#1103#1080#1085'\Doc' +
'uments\Demo.mdb;Persist Security Info=False'
LoginPrompt = False
Mode = cmShareDenyNone
Provider = 'Microsoft.Jet.OLEDB.4.0'
Left = 528
Top = 96
end
end
|