问题
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. 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. So I copied the entire database over to the EC2 instance. 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. the name on the EC2 server is WIN-B4PF9V1I0OJ if it's any help.
the connection string in the webconfig file looks like this :
<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="data source=LOCALHOST\SQLEXPRESS;initial catalog=YubiDB;integrated security=True;MultipleActiveResultSets=True;App=EntityFramework"" 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>
回答1:
It's actually pretty easy to get a GUI to create a connection string on any Windows computer, even without VS.
Create an empty text file, but name it with a ".udl" extension. The file name does not matter--I use 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. Once done, open the udl file up in your favorite text editor and scrape out the connection string.
来源:https://stackoverflow.com/questions/28992243/getting-ms-sql-server-connection-string-without-using-visual-studio