// ClearDataConnConfiy.ini  //ini配置文件[ServerInfo]   
ServerIP=AJAX\SA  
SQLDBName=UFDATA_002_2006   
SQLUserID=sa   
SQLPwd=ajax //以下是 调用ini文件及连接数据库代码 type 
    QueryClearData: TADOQuery;{读取数据库连接文件 }
function   Get_ClearData_Str(FileName:String):String;
      var   
          ServerIP,SQLDBName,SQLUserName,SQLPwd:string;
      begin
          Result :='';
          with   TInifile.Create(ExtractFilePath(Paramstr(0))+'ClearDataConnConfiy.ini')   do
          begin
              try   
                  ServerIP:=ReadString('ServerInfo','ServerIP','');   
                  SQLDBName:=ReadString('ServerInfo','SQLDBName','');   
                  SQLUserName:=ReadString('ServerInfo','SQLUserID','');
                  SQLPwd:=ReadString('ServerInfo','SQLPwd','');
              finally
                  Free;
              end;
Result :='Provider=SQLOLEDB.1;Password='+SQLPwd+';Persist Security Info=True;User ID='+SQLUserName+';Initial Catalog='+SQLDBName+';Data   Source='+ServerIP;
          end;    end;
procedure TMainForm.FormShow(Sender: TObject);
 var
    Ini_FileName:String;
begin
  { 检查数据库时候连接 }    Ini_FileName:=ExtractFilePath(application.ExeName)+'ClearDataConnConfiy.ini';
     // Ini_FileName:=GetExePath + 'ClearDataConnConfiy.ini';    if   not FileExists(Ini_FileName)   then
      begin
          ShowMessage('数据库连接配置文件不存在!');
          Application.Terminate;
      end
    else
      begin
         with   QueryClearData   do
          begin
              //Active:=true;
             // Connected := true;
              ConnectionString:=Get_ClearData_Str(Ini_FileName);
              //Active:=true;
         {     try
                Connected:=false;
                //Active:=false;
              except
                showMessage('数据库连接失败!请检查配置文件:'+Ini_FileName);
              end;   }              close;
              sql.clear;
              {sql.Add('select CD1.cWhCode as 仓库编号,CD1.cInvCode as 存货编号,CD1.cBatch as 批号,CD1.iQuantity as 结存数量');
              sql.Add('from CurrentStock CD1');
              sql.Add('where CD1.iQuantity=0');
              }
              sql.Add('select * from CurrentStock');
              open;
          end;      end;
end;错误提示:Project LeeO.exe raised exception class EOleException with message '连接字符串属性无效'. process stopped. use step or Run to Continue.折腾了一天了,始终不知道什么问题。
特来求助~~

解决方案 »

  1.   

    你调试一下或者用SHOWMESSAGE看看字符串到底是什么~~
    Paramstr(0)如果路径中包含空格的话会出现问题,所以偶一般是用APPLICATION.EXENAME
      

  2.   

    连接字符串属性无效 说明你字符串的属性配置错误了 检查一下用户名,密码,数据源,和database
      

  3.   

    ServerIP=AJAX\SA  
    这是什么??
    服务器名可以带'\'的么??这个是非法字符
    你只要设
    ServerIp=Ajax
    就行了吧
      

  4.   

    这是什么??你只要设
    ServerIp=Ajax
    就行了吧===================================服务器名可以带'\'的么??这个是非法字符
    服务器是可以带这个 '\' 字符的。