简体   繁体   中英

Connection string for remote SQL server 2008 without SQL Management Studio

I know its a classic problem, but I am too novice to even comprehend the basics (sorry). I have this ASP.NET "Website" with databases (SQL Server 2008), which I am trying to deploy on a Remote Host Server (HostGator) using WebSite Copy tool of VS 2010.

In VS 2010, I could grab the Connection string directly through the "property" of the database, which turned out to be:

Data Source=.\\SQLEXPRESS;AttachDbFilename="C:\\Users\\myName\\Documents\\Visual Studio 2010\\WebSites\\Experiment\\App_Data\\data.mdf";Integrated Security=True;User Instance=True

Now, I know that a website called http://connectionstrings.com/ exists, but its too overwhelming for me at first glance.

My current connection string:

Data Source=domainName.com\\SQLEXPRESS;AttachDbFilename=C:\\inetpub\\vhosts\\domainName\\httpdocs\\Experiment\\App_Data\\data.mdf;Integrated Security=True;User Instance=True

I am pretty sure, that this is wrong as its giving me the classic error of:

A network-related or instance-specific error occurred while establishing a connection to SQL Server..

But I don't know how to fix it. Where to start looking, how to initiate, how to get the parameters required to build the connection string. How to find the path of the AttachDbFilename ? Can you please help?

I believe, that connection string is the only parameter which needs to be modified. If there's something else, then please suggest? Also, I keep coming across the usage of SQL Management Studio to make things work, I don't have that, so is it hard to accomplish this without it?

Please help, thanks.

You can't specify a directory relative to your own machine. Change AttachDbFilename to

AttachDbFilename=|DataDirectory|data.mdf

The specifics for Data Source should be given to you from your hosting company, as well the security model (probably you need to use a specific user)

You can download SqlServer Management Studio Express from this link

Man,

What do you think about HttpServerUtility.MapPath Method . It returns the physical file path that corresponds to the specified virtual path on the Web server.

[]'s

When you get your hosting. They will provide the connection string for you. like this

  <add name="ConnectionStringName" 
       connectionString="Data Source=localhost;Database=YourDatabaseName;Uid=YourUserNameForDatabase;password=yourpassword;"
  providerName="System.Data.SqlClient" />

Let me know, if you need more help

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