SQL Server 连接字符串 [英] SQL Server connection string

查看:44
本文介绍了SQL Server 连接字符串的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我猜你会收到数百个这样的问题,但这里有:

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

所以我试图让 Honeywell Dolphin 6100 移动设备(CE5.0、.NET Compact Framework)与我正在开发的机器上安装的 SQL Server Express 2008 数据库进行通信.

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.

我是 SQL Server 和移动开发的完全新手,并且对 C# 仍然有点陌生(是的,我知道,在这里跳到了深渊,嗯?:D)

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)

到目前为止我有:

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

该应用程序部署到 6100 时非常愉快,但最后一行出现了一个模糊的SQL 异常"错误.

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.

我可以毫无问题地连接到 Management Studio 中的数据库.

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

那么,是连接字符串有问题,还是我在 SQL Server 中没有正确完成?

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

提前致谢.

顺便说一句,这个网站很棒,这里有一些知识渊博的人.

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

推荐答案

CE 5.0 不支持集成安全性.我相信第一个支持它的版本是 mobile 6.1.在任何情况下,您都不能在您的配置中使用 SSPI.您必须创建一个 SQL Server 用户并将其用作您的连接凭据.

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.

除了使用 UID/PWD 进行连接之外,还可以尝试的另一件事是通过 IP 引用服务器.DNS 解析可能未在您的设备上正确进行.嗯,这完全是另一个问题.您的设备是否与 SQL Server 位于同一网络?

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?

为了将来参考,将此方便的 URL 提交到内存中:http://connectionstrings.com

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

编辑

让我们看看类似...如果命名 SQL Server 实例:

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

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

如果没有命名的 SQL Server 实例:

if not named SQL Server instance:

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

这篇关于SQL Server 连接字符串的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆