连接字符串

连接字符串:

www.connectionstrings.com

 

应用:

http://topic.youkuaiyun.com/t/20061127/23/5189545.html#

 

      self.ADOConnection1.Connected:=false;  
      self.ADOConnection1.ConnectionString:='Provider=OraOLEDB.Oracle;Data   Source=datasource;User   Id=user;Password=123;';  
      self.ADOConnection1.Connected:=true;  
      self.ADOConnection1.Connected:=false;  
      self.ADOConnection1.ConnectionString:='Provider=Microsoft.Jet.OLEDB.4.0;Data   Source=C:/Documents   and   Settings/lidexian/桌面/123.mdb;Persist   Security   Info=False';  
      self.ADOConnection1.Connected:=true;  
      self.ADOConnection1.Connected:=false;  
      self.ADOConnection1.ConnectionString:='Driver={SQL   Server};Server=myServerAddress;Database=myDataBase;Uid=myUsername;Pwd=myPassword;';  
      self.ADOConnection1.Connected:=true;

 

数据库配置文件管理:

一般文本文件、UDL文件、INI文件等

一般文本:

procedure   TForm1.FormCreate(Sender:   TObject);  
  var  
      T:   Tstrings;  
  begin  
      T   :=   Tstringlist.Create;  
      T.LoadFromFile('xxxx');  
      AdoConnection1.Connected   :=   false;  
      AdoConnection1.ConnectionString   :=T.Text;  
      try  
          AdoConnection1.Connected   :=   true;  
      except   on   E:   Exception   do  
          begin  
              showmessage(E.Message);  
              close;  
          end;  
      end;  
  end;

 

UDL:

新建一个空文本文件,保存为a.udl  
  双击a.udl进行数据库的连接...  
   
  调用:  
  ADOConnection1.ConnectionString:=   'FILE   NAME=c:/a.udl';  
   
  要修改连接信息,双击a.udl进行修改就行了..

 

INI文件:

  var    
      iFile:TIniFile;  
      ConnStr:string;//从INI文件中得到的连接字符串  
   
  ..  
   
   
  iFile:=TiniFile.Create('你的INI文件名');  
  try  
      ConnStr:=iFile.ReadString('Connection','ConnectionString','');  
      //写字符串  
      //iFile.WriteString('Connection','ConnectionString',ConnStr;      
  finally  
      iFile.Free;  
  end;  

 

评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值