简体   繁体   English

在不使用visual studio的情况下获取MS SQL Server连接字符串?

[英]Getting MS SQL Server connection string without using visual studio?

so currently, I have after a fair amount of trouble, managed to get my ASP.NET website hosted on an windows EC2 instance with IIS and MSQL SERVER 2008 r2. 所以目前,我遇到了相当多的麻烦,设法将我的ASP.NET网站托管在带有IIS和MSQL SERVER 2008 r2的Windows EC2实例上。 However, the website is unable to access the database because the connection string is set to the directory LOCALHOST\\SQLEXPRESS where i was hosting the database on my own computer. 但是,网站无法访问数据库,因为连接字符串设置为LOCALHOST \\ SQLEXPRESS目录,我在自己的计算机上托管数据库。 So I copied the entire database over to the EC2 instance. 所以我将整个数据库复制到EC2实例。 Usually I generate a new connection string by using visual studio's connect to datasource but seeing as there is no visual studio on my ec2 instance, I cannot use that facility to generate the new string. 通常我通过使用visual studio的connect to datasource生成一个新的连接字符串,但是因为我的ec2实例上没有visual studio,所以我无法使用该工具生成新的字符串。 the name on the EC2 server is WIN-B4PF9V1I0OJ if it's any help. 如果有任何帮助,EC2服务器上的名称是WIN-B4PF9V1I0OJ。

the connection string in the webconfig file looks like this : webconfig文件中的连接字符串如下所示:

<connectionStrings>
    <add name="YubiDBEntities" connectionString="metadata=res://*/App_Code.Model.csdl|res://*/App_Code.Model.ssdl|res://*/App_Code.Model.msl;provider=System.Data.SqlClient;provider connection string=&quot;data source=LOCALHOST\SQLEXPRESS;initial catalog=YubiDB;integrated security=True;MultipleActiveResultSets=True;App=EntityFramework&quot;" providerName="System.Data.EntityClient" />
    <add name="YubiDBConnectionString" connectionString="Data Source=LOCALHOST\SQLEXPRESS;Initial Catalog=YubiDB;Integrated Security=True;MultipleActiveResultSets=True;Application Name=EntityFramework" providerName="System.Data.SqlClient" />
  </connectionStrings>

It's actually pretty easy to get a GUI to create a connection string on any Windows computer, even without VS. 实际上,即使没有VS,在任何Windows计算机上创建连接字符串都非常容易。

Create an empty text file, but name it with a ".udl" extension. 创建一个空文本文件,但使用“.udl”扩展名命名。 The file name does not matter--I use db.udl. 文件名无关紧要 - 我使用db.udl。 Once the file is created, double-click on it and you will see a GUI open up to guide you building your connection string. 创建文件后,双击它,您将看到一个GUI,用于指导您构建连接字符串。 Once done, open the udl file up in your favorite text editor and scrape out the connection string. 完成后,在您喜欢的文本编辑器中打开udl文件并清除连接字符串。

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

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