procedure TForm1.Edit2Exit(Sender: TObject);
begin
if Label3.Visible =true then
if (edit1.Text ='') or (edit2.Text ='') then
exit
else
if edit2.text='?' then
wlsjk:='Provider=SQLOLEDB.1;Persist Security Info=False;User ID=sa;Initial Catalog=master;Data Source='+edit1.Text
else
wlsjk:='Provider=SQLOLEDB.1;Password='+edit2.text+';Persist Security Info=False;User ID=sa;Initial Catalog=master;Data Source='+edit1.Text ;
try
adodataset2.ConnectionString :=wlsjk;
adodataset2.CommandText :='select * from sysdatabases';
// adodataset2.Refresh;
adodataset2.Open;
adodataset2.Active
except
showmessage('服务器不存在,或密码有误!');
end;
adodataset2.First;
while not (adodataset2.Eof) do
begin
if adodataset2.FieldByName('dbid').AsInteger>6 then
combobox1.Items.Add(adodataset2.FieldByName('name').AsString );
adodataset2.MoveBy .Recordset.MoveNext;
end;end;
上面代码运行到//?????????????处,根本不是取得adodataset2.FieldByName('name')的值,而是数据库名字master,为什吗?帮帮忙
begin
if Label3.Visible =true then
if (edit1.Text ='') or (edit2.Text ='') then
exit
else
if edit2.text='?' then
wlsjk:='Provider=SQLOLEDB.1;Persist Security Info=False;User ID=sa;Initial Catalog=master;Data Source='+edit1.Text
else
wlsjk:='Provider=SQLOLEDB.1;Password='+edit2.text+';Persist Security Info=False;User ID=sa;Initial Catalog=master;Data Source='+edit1.Text ;
try
adodataset2.ConnectionString :=wlsjk;
adodataset2.CommandText :='select * from sysdatabases';
// adodataset2.Refresh;
adodataset2.Open;
adodataset2.Active
except
showmessage('服务器不存在,或密码有误!');
end;
adodataset2.First;
while not (adodataset2.Eof) do
begin
if adodataset2.FieldByName('dbid').AsInteger>6 then
combobox1.Items.Add(adodataset2.FieldByName('name').AsString );
adodataset2.MoveBy .Recordset.MoveNext;
end;end;
上面代码运行到//?????????????处,根本不是取得adodataset2.FieldByName('name')的值,而是数据库名字master,为什吗?帮帮忙
adodataset2.Open; //Open与Active使用一个即可,作用相同
adodataset2.Active