我正在尝试访问.ini文件,其中存储了powerbuilder的数据库信息

时间:2016-10-13 11:50:29

标签: powerbuilder powerbuilder-conversion

当我运行此代码时,我将默认值设为“抱歉”而不是原始值。 这是我的代码:

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" )

请帮我修复此查询...

1 个答案:

答案 0 :(得分:3)

您没有提供足够的信息来最终回答。而不是让这个没有答案,将提供额外的信息,以便它可以回答并帮助其他人同样的挑战。

情景1

名为c:\ database.ini的INI文件不存在

结果

对ProfileString函数的所有三次调用都返回默认的'Sorry',因为没有ini文件

场景2

INI文件存在,内容如:

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

结果:第三个​​ProfileString返回默认值,因为'LogId'不在INI文件中

// 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'