大哥们:
我放置了一个ADOConnecion控件
设好属性后,测试连接,他说连接成功?
又放置了一个ADOQuery控件,他的Connection属性设置为DataModule2.ADOConnection1
下面是打开的代码,调试时一执行到open就说miss connection or connection string:
procedure Tmainform.setrecordarray(tablename,KP:string;tixing:integer);
var
i:integer;
value:integer;
begin
with ADOQuery1 do
begin
close;
with sql do
begin
clear;
add('select ID from '+tablename); add('where Knowledgepoint= '+KP);
end;
open;
end;
ADOQuery1.first;
i:=1;
while not(ADOQuery1.eof) do
begin
value:=ADOQuery1.fieldbyname('ID').value;
recordarray[tixing,strtoint(KP),i]:=value;
ADOQuery1.next;
i:=i+1;
end;
recordarray[tixing,strtoint(KP),i]:=-1;
end;
我放置了一个ADOConnecion控件
设好属性后,测试连接,他说连接成功?
又放置了一个ADOQuery控件,他的Connection属性设置为DataModule2.ADOConnection1
下面是打开的代码,调试时一执行到open就说miss connection or connection string:
procedure Tmainform.setrecordarray(tablename,KP:string;tixing:integer);
var
i:integer;
value:integer;
begin
with ADOQuery1 do
begin
close;
with sql do
begin
clear;
add('select ID from '+tablename); add('where Knowledgepoint= '+KP);
end;
open;
end;
ADOQuery1.first;
i:=1;
while not(ADOQuery1.eof) do
begin
value:=ADOQuery1.fieldbyname('ID').value;
recordarray[tixing,strtoint(KP),i]:=value;
ADOQuery1.next;
i:=i+1;
end;
recordarray[tixing,strtoint(KP),i]:=-1;
end;
ADOConnection1的Connected早就设置成true了!
begin
close;
//加下面一段代码高度一下
if not Assigned(DataModule2) then
begin
ShowMessage('DataModule2 not create');
Exit;
end;
//
with sql do
begin
clear;
add('select ID from '+tablename); add('where Knowledgepoint= '+KP);
end;
是没有创建DataModule2
但我在file /new菜单里的data Module创建的呀
他是一个unit1单元
我在要用到他的单元中,已经use了!
该怎么办?
放在Application.CreateForm(mainForm,TMainForm)
前面了,但不能open呀?
即使我不用DataModule
把ADOConnection和ADOQuery同时放在mainForm上
也不能open呀?
还是说没有connection or connection strings