谢谢你上次的解答,我回去把inital catalog ='+EDIT1.TEXT+',调试能通过。
可是在按下bitbtn1click,打开文件对话框,在D:\mssql7\data\pubs.mdf(选择其他任何数据库文件),显示pubs.mdf不能打开,已被使用。事实上SQL SERVER 并没有启动。请问这是什么原因?
例如:用EDIT1显示选择数据库,用COMBOBOX选择表。服务器名是CYP。
下面是一段代码: 
procedure tform1.bitbtn1click(sender:tobject); 
var str:string; 
begin 
if opendialog1.execute then 
edit1.text:=opendiaolog1.filename; 
adoconnection1.provider:='sqloledb.1';
str:='datasource(或者server)=cyp;inital catalog (或者database)=‘+edit1.text+’;username=sa';adoconnection1.close; 
try 
adoconnection1.connectionstring:=str; 
adoconnection1.connected:=true;
adoconnection1.gettablenames(combobox1.items,false) 
except 
messagedlg('连接失败',mterror,[mbok],0); 
end; 
end; 
procedure tform1.combobox1change(); 
begin 
adotable1.close; 
adotable1.connection:=adoconnection1; 
adotable1.tablename:=combobox1.text; 
adotable1.active:=true; 
datasource1.datasource:=datasource1; 
end; 
其中:combobox1用于选择表,EDIT1显示库文件