本函数用于构成数据库连接字,数据库连接采用的是ado.connection
完整的连接字为:
Provider=OraOLEDB.Oracle.1;Password=80327;Persist Security Info=True;User ID=Zium;Data Source=Zium 
问题:连接不能正常打开 function gfunDBconnTrue(sUsername:string;sPassword:string;sSource:string):boolean;
    var
      connTest: TADOConnection;
      adodbSet:TADODataSet;
      sTemp:string;
    begin
      Result:=True;
      sTemp:='Provider=OraOLEDB.Oracle.1;Password='+sPassword;
      sTemp:=sTemp+';Persist Security Info=True;User ID='+sUsername;
      sTemp:=sTemp+';Data Source='+sSource;
      try
        connTest.Open;
      except
        application.MessageBox('bug','DB Error',MB_OK);
       Result:=False;
      end;
      connTest.Close;
      connTest.Free;
    end;

解决方案 »

  1.   

    晕倒,你什么时候写了conntest.connectionstring:=stemp;
    简直晕倒,这也没写那也没写怎么搞打得开嘛?
      

  2.   

    晕了吧!!!写完了不赋值,怎么用呀!
    conntest.connectionstring:=stemp;
      

  3.   

    begin
          Result:=True;
          sTemp:='Provider=OraOLEDB.Oracle.1;Password='+sPassword;
          sTemp:=sTemp+';Persist Security Info=True;User ID='+sUsername;
          sTemp:=sTemp+';Data Source='+sSource;
          conntest.connectionstring:=stemp;
      

  4.   

    添加 conntest.connectionstring:=stemp;后,依然有错
      

  5.   

    除了楼上加的conntest.connectionstring:=stemp;外
    好像 conntest的没有create
    改一下:      connTest := TADOConnection.Create(nil);
          conntest.connectionstring:=stemp;
          try
            connTest.Open;
          except
            application.MessageBox('bug','DB Error',MB_OK);
           Result:=False;
          end;
          connTest.Close;
          connTest.Free;
      

  6.   

    connTest := TADOConnection.Create(nil);
    中的nil是什么组件呀?