on 2013 Sep 10 1:35 AM
I am using iAnywhere.Data.SQLAnywhere.v3.5 In a Microsoft .Net project, I try to connect to Sql Anywhere server by using SAConnection by passing a connection string in the SAConnection constructor.
I am having trouble open a connection that the database file name is in Chinese, e.g. the following connection string will result in db file not found error:
mySaConnection = new SAConnection(@"UID=DBA;PWD=sql;DBF=C:\\\\中文名字.db"); mySaConnection.Open();
Does anyone know what I need to do?
Thanks in advance
Request clarification before answering.
A couple of questions, and then I'll take a guess:
My guess to the second question is no... since you are using the DBF (aka DatabaseFile) parameter. Note that when you don't specify a server name then the server name is derived from the database filename of the first database started on the server's command line. So in your case the server name of the auto-started database will be the Chinese name.
I believe that there have been some issues when it comes to non-ascii characters in server names. Compounding the issue is the character sets used and whether there are any conversions required between the application, OS, and server character sets. This is why the documentation states:
Non-ASCII characters are not recommended in server names.
So I would recommend that you:
HTH
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.
Hi Mark:
Thanks for your reply.
We are using version 12.
You are right, I have not started server prior to trying to connect. But if we suspect that the server is trying to use the db name as the server name, then I modified the connection string to the following(i.e. I specify server name as TEST): mySaConnection = new SAConnection(@"UID=DBA;PWD=sql;ENG=TEST;DBF=C:\\中文名字.db"); mySaConnection.Open();
I still get the specified database not found error.
The connection string that you have specified (with ENG=TEST and DBF=C:中文名字.db) won't work because it tells the client to try to connect to the server named 'TEST' and on that server try to connect to the database. Since the server is not running it cannot succeed.
You could try specifying a START= connection parameter. e.g. "UID=DBA;PWD=sql;DBN=中文名字;START=dbsrv12 -n TEST C:\\中文名字.db" - Note that I have used DBN and not DBF!. This says: try to connect to database named "中文名字" on the default server on the local computer, and if you cannot connect then start a server using dbsrv12 giving it the name of 'TEST' and start the database which is located at C:\\中文名字.db
FWIW, I do not recommend using the default server so I would actually recommend using the connection string: "UID=DBA;PWD=sql;ENG=TEST;DBN=中文名字;START=dbsrv12 -n TEST C:\\中文名字.db -xd" - this is very similar to the above but tries to connect to the local server named TEST rather than the default server. The -xd switch on the start line tells the server to NOT become the default server on the computer (i.e. I recommend always using the -xd switch in production systems since this will reduce the probability that client applications will connect to the wrong server!).
HTH
User | Count |
---|---|
76 | |
30 | |
10 | |
8 | |
8 | |
7 | |
7 | |
5 | |
4 | |
4 |
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.