on 2013 Feb 01 11:12 AM
I am trying to connect to a Micros database (Sybase database for Micros registers). The database is installed on a Windows 7 pc and uses SQL Anywhere 11. My application needs to run in multiple restaurants, which means each restaurant or franchise may have different username/password to log in. For this reason, I stored the values in tables. The strange problem I have is that if I hard-code the username & password into a program to test the connection, I can connect and extract the data from the Micros database. When I change the code and use the username & password values from the table, I can't connect. I know the password in the table is correct because I copied it from the table into my code! Here's the code that doesn't work:
cSQLDriver = 'SQL Anywhere 11' cConnStr = 'Driver=' + ALLTRIM(cSQLDriver) cConnStr = cConnStr + ';' + 'Servername=' + Alltrim(registerinfo.servername) cConnStr = cConnStr + ';' + 'UID=' + Alltrim(registerinfo.username) cConnStr = cConnStr + ';' + 'PWD=' + Alltrim(registerinfo.password) cConnStr = cConnStr + ';' + 'Database=' + Alltrim(storuser.poll_path) cConnStr = cConnStr + ';' + 'AutoStop=No' cConnStr = cConnStr + ';' + 'LOG=c:microsdatasql_log.txt' lnConn = SQLSTRINGCONNECT(cConnStr, .T.)Replacing only the lines for username & password with the following 2 lines, I can get connected:
cConnStr = cConnStr + ';' + 'UID=dba' cConnStr = cConnStr + ';' + 'PWD=microspwd'
I added a message box to display the entire connection string and both showed exactly the same thing. The log also shows the same username/password information for both attempts.
Has anybody seen this before? Any ideas how I can get the connection to work using the field values?
Any help or suggestions are greatly appreciated. Karen
Request clarification before answering.
I'm not familiar with VFP, but the first thing I think of is "what kind of string is returned by 'Alltrim'"? Is it possible it's returning an ASCIIZ string with a trailing chr(0)? This is usually invisible when shown with a message box. Or perhaps is a unicode string?
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.
User | Count |
---|---|
41 | |
15 | |
10 | |
9 | |
6 | |
5 | |
5 | |
5 | |
5 | |
4 |
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.