ACCESS到SQL关键语句怎么变

来源:百度知道 编辑:UC知道 时间:2024/06/06 01:54:55
DELPHI中连接ACCESS的数据库语言是:
Path:=ExtractFilePath(ParamStr(0));
Connection.ConnectionString:='Provider=Microsoft.Jet.OLEDB.4.0;Data Source='+ Path+'onlineexam.mdb;Persist Security Info=true';

try
Connection.Open;
except
MessageBox(0,'无法打开数据库','错误',MB_OK);
end;
如果要连接SQL数据库要变成什么样啊?
急啊!

ServerName:='服务器名称';//第一次需要输入,或是选择,正确连接后保存到INI 文件,或是注册表,下次直接读出来
Connection.ConnectionString:='Provider=SQLOLEDB.1;Persist Security Info=False;User ID=sa;Initial Catalog='数据库名称';Data Source='+ServerName;

try
Connection.Open;
except
MessageBox(0,'无法打开数据库','错误',MB_OK);
end;