简体   繁体   中英

SQL Server connection string

I'm guessing you get hundreds of these questions, but here goes:

So I'm trying to get a Honeywell Dolphin 6100 mobile device (CE5.0, .NET Compact Framework) to talk to an SQL Server Express 2008 database installed on the machine I'm developing on.

I am a complete newbie to SQL Server and mobile development, and am still a little green in C# (yeah I know, jumped in the deep end here, eh? :D)

So far I have:

string sConnection = @"Data Source=JEZ-LAPTOP;DataBase=EMS_Main;Integrated Security=SSPI;";   
SqlConnection sqc = new SqlConnection(sConnection);
sqc.Open();

The app deploys quite happily to the 6100, but the last line bugs out with a vague "SQL Exception" error.

I have tried changing the Data Source to include instance names, slashes and dots before it etc etc (even though server is just using the default instance), to no avail.

I can connect to the database in Management Studio with no problems.

So, is the connection string at fault, or is it something I haven't done correctly in SQL Server?

Thanks in advance.

This site is awesome btw, some very knowledgable guys here.

CE 5.0 does not support integrated security. I believe the first version to support it was mobile 6.1. In any case, you cannot use SSPI with your configuration. You'll have to create a SQL Server user and use that as your connection credentials.

Another thing to try, besides using a UID/PWD to connect is to refer to the server by IP. It's possible that DNS resolution is not taking place properly on your device. Hmm, that is a whole nother issue. Is your device on the same network as the SQL Server?

And for future reference, commit this handy URL to memory: http://connectionstrings.com

EDIT

Let's see something like... if Named SQL Server instance:

@"Data Source=192.168.0.56\SERVER_NAME;DataBase=EMS_Main;User Id=joe;Password=pwd;";

if not named SQL Server instance:

@"Data Source=192.168.0.56;DataBase=EMS_Main;User Id=joe;Password=pwd;";  

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM