Jump to content

Recommended Posts

Posted

In Web Mode, can i read from INI file?

 

i use the following code.

 

 

var
  INI            : TIniFile;
  strINIFilePath : String;
  strReadedVal   : string;
begin
  Result := False;
  Try
  strINIFilePath := GetCurrentDir + 'Config.ini';
  strReadedVal   := EmptyStr;
  If FileExists(strINIFilePath) Then
  Begin
    Ini := TIniFile.Create(strINIFilePath);
    Try
      strReadedVal := Ini.ReadString(strSec,strTag, '0');
      strVal := strReadedVal;
      Result := True;
    Finally
      FreeAndNil(Ini);
    End;
  End;
  except
    Result := False;
  End;
 
this work in normal VCL Application, but not work in ISAPI DLL , I want to use the INI file to Store the SQL Server Connection String
and other Values

 

Posted

Why don't you use UDL files ?

Is easy to use than INI files

Example :

 

  dbConecta.Close;
  dbconecta.ConnectionString :=
    'FILE NAME=' + UniServerModule.StartPath + '\Files\dbConecta.udl';
  dbconecta.Open;

 

 

Posted

It easy to work to udl files, you just only has to create a txt file and change the extension txt by udl.

Example : myDbConnect.txt by myDbConecct.udl,

Then you just only has to click and you will see the option to connect to any database

 

 

Ronny Encarnacion

  • Upvote 1
Posted

In case you want to stick to the ini files :

 

 

function ReadSetup:boolean;

  var
                          fname:string;
                                ini:TIniFile;
  begin
  fname:=UniServerModule.StartPath+'etc\your_conf_file.ini';
  if FileExists(fname) then
     begin
       Conn.Connected  := False;
       ini:=TIniFile.Create(fname);
       try
          ..... Read the stuff you want here
          result:=True;
       finally
          ini.Free;
       end;
     end
     else begin
       UniServerModule.Logger.AddLog('No conf file ->'+fname);
       result:=False;
     end;
end;
 

 

  • Upvote 1
  • 1 month later...

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.

Guest
Reply to this topic...

×   Pasted as rich text.   Paste as plain text instead

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

×
×
  • Create New...