9494 try with ADOConnection1 do begin Connected := false; ConnectionString := 'Provider=SQLOLEDB.1;Persist Security Info=False;User ID=sa;Initial Catalog=' + trim(Edit_DataBaseName.text) + ';Data Source=' + trim(Edit_ServerName.text); Connected := true; end; with ADOQuery1 do begin if Active then Close; Open; end; with ADOQuery2 do begin if Active then Close; Open; end; except Application.MessageBox('唉,这么简单的问题你还要出错?一定是写错了。','SongInfo',mb_OK + MB_ICONQUESTION); end; end;
设置ConnectionString就可以了
1:OLE DB提供者,选择Microsoft OLE DB Provider for SQL Server;
2: 输入NT4服务器名,选择登录方式、用户名、密码,选择要连接数据库名;
Provider=SQLOLEDB.1;
Password=aaaa;
Persist Security Info=True;
User ID=sa;
Initial Catalog=Master;
Data Source=hzow
你双击元件就可以Build出一个ConnectionString;
connectionstring应怎样写?
try
with ADOConnection1 do
begin
Connected := false;
ConnectionString := 'Provider=SQLOLEDB.1;Persist Security Info=False;User ID=sa;Initial Catalog=' + trim(Edit_DataBaseName.text) + ';Data Source=' + trim(Edit_ServerName.text);
Connected := true;
end;
with ADOQuery1 do
begin
if Active then
Close;
Open;
end;
with ADOQuery2 do
begin
if Active then
Close;
Open;
end;
except
Application.MessageBox('唉,这么简单的问题你还要出错?一定是写错了。','SongInfo',mb_OK + MB_ICONQUESTION);
end;
end;