-
May 22nd, 2014, 12:47 PM
#1
VB6 getprivateprofle string problem
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.
==========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"
Thanks,
Gene
-
May 24th, 2014, 12:36 AM
#2
Re: VB6 getprivateprofle string problem
There really is not much it could be,
File not at the location, wrong filename
Not able to access file
Not finding a match to your area or section
You could try adding a line after you set the filename something like
Code:
Debug.Print "Filename =: " & Dir$(sfilename)
Which should show you the filename if it is there else DIR$() will return an empty string
I'm not sure if the INI read routine would have an issue with spaces or tabs on the section name or not but you may want to check to make sure that there are no trailing spaces and/or tabs there, if there are that could possibly be the problem.
Always use [code][/code] tags when posting code.
-
May 24th, 2014, 12:52 AM
#3
Re: VB6 getprivateprofle string problem
Not a good idea to keep the info in an INI file. It's pure text
Tags for this Thread
Posting Permissions
- You may not post new threads
- You may not post replies
- You may not post attachments
- You may not edit your posts
-
Forum Rules
|
Click Here to Expand Forum to Full Width
|