Please be aware that the SAP SQL Anywhere Forum will be shut down on August 29th, 2024 when all it's content will be migrated to the SAP Community.

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

asked 01 Feb '13, 11:12

KarenG's gravatar image

accept rate: 0%

edited 15 Mar '13, 20:33

Mark%20Culp's gravatar image

Mark Culp


I suggest saving both connection strings into the file for careful examination with a binary viewer. There are no miracles ;).

(04 Feb '13, 04:00) Dmitri

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?

permanent link

answered 02 Feb '13, 09:44

BudDurland's gravatar image

accept rate: 0%

Your answer
toggle preview

Follow this question

By Email:

Once you sign in you will be able to subscribe for any updates here



Answers and Comments

Markdown Basics

  • *italic* or _italic_
  • **bold** or __bold__
  • link:[text]( "title")
  • image?![alt text](/path/img.jpg "title")
  • numbered list: 1. Foo 2. Bar
  • to add a line break simply add two spaces to where you would like the new line to be.
  • basic HTML tags are also supported

Question tags:


question asked: 01 Feb '13, 11:12

question was seen: 3,784 times

last updated: 15 Mar '13, 20:33