启用远程连接到SQL Express与脚本 [英] Enable remote connections to sql express with a script

查看:266
本文介绍了启用远程连接到SQL Express与脚本的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我部署与SQL Server的应用程序明确2008年。我已经包括了我的应用程序的先决条件部分:

I am deploying an application with sql server express 2008. In the prerequisites section of my application I have included:

其结果是当用户安装我的应用程序将安装的SQL Express作为。还有

As a result when a user installs my application it will install sql express as well.

然后我将能够连接到数据库引擎为:

Then I will be able to connect to that database engine as:

        try
        {
            // database should be in the same network
            SqlConnection conn =
                new SqlConnection(@"Data Source=.\sqlexpress; Integrated Security=True");
            conn.Open();
            MessageBox.Show("Connection succesfull");
        }
        catch
        {
            MessageBox.Show("Unable to connect");
        }






现在,当我安装不同的应用程序(客户端版本),我会希望能够连接到数据库引擎。我设法做一些像连接到它:


Now when I install a different application(client version) I will like to be able to connect to that database engine. I managed to connect to it by doing something like:

        try
        {

            SqlConnection conn =
                new SqlConnection(@"Data Source=192.168.0.120\sqlexpress,22559; USER=sa; PASSWORD=*********");
            conn.Open();
            MessageBox.Show("Connection succesfull");
        }
        catch
        {
            MessageBox.Show("Unable to connect");
        }

为了对代码工作,我不得不做以下几点:

In order for that code to work I had to do the following:

我怎么能配置此的代码?当我部署我的应用程序,我想我的应用程序安装的SQL Express喜欢它,但我也whant启用TCP / IP连接,使一些端口,最后该帐户SA创建密码,因为我不能够连接到数据库remotly如果sa帐户没有密码。

How could I configure this with code? When I deploy my application I want my application to install sql express like it does but I also whant to enable tcp/IP connections, enable some ports and lastly create a password for the account "SA" because I am not able to connect to the database remotly if the sa account does not have a password.

或者,也许我问得多,我做错事。也许我应该做这一切只是为了那我就没有部署数据库引擎刨数据库。无论是比较容易。我有一个很难部署此也许这将是eassier来,以便到本地数据库远程上创建CRUD操作的WCF服务一起deoploy本地数据库。

Or maybe I am asking to much and I am doing the wrong thing. perhaps I should do all this just for the database that I am planing on deploying not the database engine. whatever is easier. I have had a hard time deploying this maybe it will be eassier to deoploy a local database along with a wcf service in order to create CRUD operations on the local database remotely.

我发现这3个环节上做类似的东西声称,我仍然不能使它发挥作用。

I found this 3 links that claim on doing something similar and I still cannot make it work.

1) http://support.microsoft.com/kb/839980

2)的 http://social.msdn.microsoft.com/Forums/en-US/sqlexpress/thread/c7d3c3af-2b1e-4273-afe9-0669dcb7bd02/

3)的 http://www.sql-questions.com/microsoft/SQL-Server/34211977/can-not-connect-to-sql-2008-express-on-same-lan的.aspx

推荐答案

下载SQL Server Express的2008年(SQLEXPR32_x86_ENU.exe),并把它放在我的C盘根驾驶。然后,我用下面的参数来安装它:

downloaded sql server express 2008 (SQLEXPR32_x86_ENU.exe) and place it in the root of my c drive. then I install it with the following parameters:

C:\SQLEXPR32_x86_ENU.exe / Q / hideconsole /动作=安装/功能= SQL / INSTANCENAME = SQLEXPRESS / enableranu = 1 / sqlsvcaccount =NT Authority\Network服务/ AddCurrentUserAsSqlAdmin / skiprules = RebootRequiredCheck / TCPENABLED = 1

C:\SQLEXPR32_x86_ENU.exe /q /hideconsole /action=Install /features=SQL /instancename=SQLEXPRESS /enableranu=1 /sqlsvcaccount="NT Authority\Network Service" /AddCurrentUserAsSqlAdmin /skiprules=RebootRequiredCheck /TCPENABLED=1

我添加/ TCPENABLED = 1,以使TCP / IP

I add /TCPENABLED=1 in order to enable TCP/IP

这篇关于启用远程连接到SQL Express与脚本的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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