求连接数据库(连接字符串)代码..

来源:百度知道 编辑:UC知道 时间:2024/05/09 07:10:07
http://www.tudou.com/v/_NFUQtdBVhE
17:10的连接字符串输入的是什么代码啊...

不一定要原始的连接字符串吧,视频又不清楚.
看过以后是连access数据库的.
通用的用这个
connstr="Provider=Microsoft.Jet.OLEDB.4.0;Data Source=" & Server.MapPath("data/1.mdb")

将data/1.mdb改成你实际的数据库路径就可以了

procedure TForm1.BitBtn3Click(Sender: TObject);
var s:string;
begin
case combobox1.ItemIndex of //这里的0和1分别是 windows NT 连接方式和 sql server连接方式
1: try
adoconnection1.Connected:=false;
s:='Provider=SQLOLEDB.1'+';'+'Password='+edit2.text+';'+'Persist Security Info=True'+';'+'User ID='+edit1.text+';'+'Initial Catalog='+combobox3.Text+';'+'Data Source='+combobox2.Text ;
adoconnection1.ConnectionString :=s;
adoconnection1.Connected:=true;
application.MessageBox('连接数据库成功!','Information',64);
except
application.MessageBox('连接数据库失败,请刷新数据库!','Information',64);
exit;
end;

0: try