首页 诗词 字典 板报 句子 名言 友答 励志 学校 网站地图
当前位置: 首页 > 教程频道 > .NET > .NET >

delphi+sql2005的有关问题

2012-03-07 
delphi+sql2005的问题本人新手,刚学delphi+数据库,我想问怎么把delphi和数据库之间相连,数据互换,越详细越

delphi+sql2005的问题
本人新手,刚学delphi+数据库,我想问怎么把delphi和数据库之间相连,数据互换,越详细越好,谢谢

[解决办法]

SQL server 连接方法

with ADOConnection1 do
begin
ConnectionTimeout:=30; //连接时间限制30秒
Connected:=false;
ConnectionString:='Provider=SQLOLEDB.1;Password=pswd'//密码
+ ';Persist Security Info=True;User ID=userid'//用户名
+ ';Initial Catalog=SQLname'//数据库空间
+ ';Data Source=192.168.0.2';//数据源 ;
Connected :=true;
Connected :=false;

end;
ADOQuery.Connection:=ADOConnection1;
except

showmessage('数据库连接错误');
application.Terminate;
end;

------------------------------------------------
access数据库连接方法

with ADOConnection1 do
begin
try
if Connected then Close;
ConnectionString := 'Provider=Microsoft.Jet.OLEDB.4.0;User ID=Admin;'//用户名
+'Jet OLEDB:Database Password= ; Data Source=' +
ExtractFilePath(ParamStr(0)) + 'db\Pmsg.mdb;' +//路径
';Persist Security Info=False';
Connected :=true;
Connected :=false;
Open;
except
socn.Close;
end;
end;

------------------------------------------------
Firebird数据库本地连接方法



with FDbcn do
begin
LoginPrompt:=False;
Close;
try
DriverName:='Firebird';//这里可以任意取名
GetDriverFunc:='getSQLDriverINTERBASE';

LibraryName:='dbexpint.dll';
VendorLib:='gds32.dll';

Params.Values['User_Name']:='sysdba';//用户名
Params.Values['Password']:='masterkey';//连接密码
Params.Values['SQLDialect']:='3';
Params.Values['Interbase TransIsolation']:='ReadCommited';
//Params.Values['Database']:=ExtractFilePath(Paramstr(0))+'\DB\SETS.DB';//数据库文件名
Connected := true;
FDbQry_Tmp.SQLConnection:=FDbcn;
except
showmessage('连接出错');
end;
end;


Firebird数据库远程连接方法我不知道,倒现在还没学会,在网上找了N天了,一直找不到答案


希望对你有用




热点排行