为什么我得到一个空字符串 [英] why am I getting an empty string
本文介绍了为什么我得到一个空字符串的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!
问题描述
我想知道我在以下代码中做错了什么,以从.ini文件中检索连接字符串.我一直收到一个空白字符串.
我在全局模块中声明了我的API.
I was wondering what I am i doing incorrectly in the following code to retrieve a connection string from an .ini file. I keep getting a blank string.
I have my API declared in my global mod.
'Get DB Loaction from INI file
Dim strDBConnect As String
sSection$ = "DB1"
sEntry$ = "DATABASECONN209"
sDefault$ = ""
sRetBuf$ = String$(256, 0) '256 null characters
iLenBuf% = Len(sRetBuf$)
sFileName$ = "c:\program files\conn.ini"
'*
X = GetPrivateProfileString(sSection$, sEntry$, _
sDefault$, sRetBuf$, iLenBuf%, sFileName$)
'*
sValue$ = Left$(sRetBuf$, X)
strDBConnect = sValue$ <<---Blank string, no return of connection string.
===========在我的.ini文件中,我有以下内容
==========In my .ini file i have the following
[DB1]
DATABASECONN209="Provider=SQLOLEDB;Data Source=222.34.34.34;Initial Catalog=xxx;User Id=appxxx;Password=@xxxpassword"
谢谢,
Gene
Thanks,
Gene
推荐答案
="DB1" sEntry
= "DB1" sEntry
="DATABASECONN209" sDefault
= "DATABASECONN209" sDefault
=" sRetBuf
= "" sRetBuf
这篇关于为什么我得到一个空字符串的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!
查看全文