1

When I run this code I get default value as "sorry" instead of original value. Here is my code:

sle_dbms.text = ProfileString( "C:\database.ini" , &
                                "DBMS" , "DBMS" , "Sorry" )
sle_database.text = ProfileString( "C:\database.ini" , &
                                "DBMS" , "ServerName" , "Sorry" )
sle_name.text = ProfileString( "C:\database.ini" , &
                               "DBMS" , "LogId" , "Sorry" )

Please help me to fix this query...

techraf
  • 64,883
  • 27
  • 193
  • 198
Muhammad Saeed
  • 81
  • 3
  • 10

1 Answers1

3

You didn't provide enough information to answer conclusively. Rather than leave this unanswered, will provide extra information so that it can be answered and help others with same challenge.

Scenario 1

INI file named c:\database.ini does not exist

Result:

All three calls to the ProfileString function return the default 'Sorry' because there was no ini file

Scenario 2:

INI File exists with the contents like:

[DBMS]
DBMS=Hello
DSN=World
ServerName=Matrix
LoginId=jdoe
DebugLevel=1

Result: Third ProfileString returns default because 'LogId' not in INI file

// These find respective file, section, key and therefore return the ini value 
ProfileString("C:\database.ini", "DBMS", "DBMS"  "Sorry") will return 'Hello'
ProfileString("C:\database.ini", "DBMS", "ServerName", "Sorry") will return 'Matrix'

// File & section found but key 'LoginId' was misspelled so returns default 'Sorry'
ProfileString( "C:\database.ini","DBMS", "LogUserId", "Sorry") will return 'Sorry' 
Rich Bianco
  • 4,141
  • 3
  • 29
  • 48