Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations TouchToneTommy on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

Reading INI values

Status
Not open for further replies.

myasin78

Programmer
Jan 26, 2004
50
US
Hello All,

I am reading ini file to open DB connection.
I am having problem generating cnn string to open DB
here is some of the code, hope to get some help.

Dim dummy As String
Dim odbcName As String * 255
Dim user As String * 255
Dim pwd As String * 255
Dim buffer as string * 1024
Dim FileName As String

FileName = ftpConfig.GetINIFileName

dummy = GetPrivateProfileString("ODBC", "name", "", odbcName, Len(odbcName), FileName)
dummy = GetPrivateProfileString("ODBC", "user", "", user, Len(user), FileName)
dummy = GetPrivateProfileString("ODBC", "pwd", "", pwd, Len(pwd), FileName)

buffer = "DSN=" + odbcName + ";UID=" + user + ";PWD=" + pwd
cnn.open buffer '' Error on this line.

when I did msgbox(buffer) i got DSN=ODBCName which is correct but not the rest of the values

thanks
 
What happens if you replace this:
buffer = "DSN=" + odbcName + ";UID=" + user + ";PWD=" + pwd
By this ?
buffer = "DSN=" & odbcName & ";UID=" & user & ";PWD=" & pwd

Hope This Helps, PH.
Want to get great answers to your Tek-Tips questions? Have a look at FAQ219-2884 or FAQ222-2244
 
I tried that I got DSN=odbcname

thanks,
myasin78
 
And this ?
dummy = GetPrivateProfileString("ODBC", "name", "", odbcName, Len(odbcName), FileName)
odbcName = Left(odbcName, dummy)
dummy = GetPrivateProfileString("ODBC", "user", "", user, Len(user), FileName)
user = Left(user, dummy)
dummy = GetPrivateProfileString("ODBC", "pwd", "", pwd, Len(pwd), FileName)
pwd = Left(pwd, dummy)
buffer = "DSN=" & odbcName & ";UID=" & user & ";PWD=" & pwd

Hope This Helps, PH.
Want to get great answers to your Tek-Tips questions? Have a look at FAQ219-2884 or FAQ222-2244
 
here is what i got:
"DSN=odbcname
;UID=myuser"

as you see there is a lot of space, I did Trim$ on them
and got nothing different.


I apperciate you help.
thanks,
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top