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

asked 10 Sep '13, 00:35

VMeng's gravatar image

VMeng
1567714
accept rate: 0%

edited 10 Sep '13, 08:37

Mark%20Culp's gravatar image

Mark Culp
22.7k9129266

Comment Text Removed

Should be escape character mySaConnection = new SAConnection(@"UID=DBA;PWD=sql;DBF=C:\你的QQ号码是什么我想加你我是新手.db");

(18 Sep '13, 22:41) mfkpie8

QQ1310636398

(18 Sep '13, 22:42) mfkpie8

A couple of questions, and then I'll take a guess:

  • What version of SQLA are you using?
  • Have you started your server prior to trying to connect?

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:

  • pre-start the database server and specify an ASCII server name using the -n server option.
  • specify the server name (SERVER=) connection parameter in your connection string.

HTH

permanent link

answered 10 Sep '13, 08:50

Mark%20Culp's gravatar image

Mark Culp
22.7k9129266
accept rate: 40%

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.

(10 Sep '13, 21:02) VMeng
Replies hidden
2

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

(10 Sep '13, 21:43) Mark Culp
Your answer
toggle preview

Follow this question

By Email:

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

By RSS:

Answers

Answers and Comments

Markdown Basics

  • *italic* or _italic_
  • **bold** or __bold__
  • link:[text](http://url.com/ "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:

×125
×7
×3

question asked: 10 Sep '13, 00:35

question was seen: 1,284 times

last updated: 18 Sep '13, 22:42