Knowledgebase: MSSQL
Do you have a connection string I can use to connect to the local MSSQL database?
Posted by Arvand Sabetian (Import) on 19 May 2009 05:13 AM

Yes. Please use the following connection string and fill in the necessary spots with your database's information:

 <add name="strConn" connectionString="Data Source=localhost;Initial Catalog=DBNAME;Integrated Security=false;User ID=DBUSERNAME;Password=DBPASSWORD" />

In some instances, the "Data Source" will need to have the Instance Name after it(\sqlexpress), such as this:

<add name="strConn" connectionString="Data Source=localhost\sqlexpress;Initial Catalog=DBNAME;Integrated Security=false;User ID=DBUSERNAME;Password=DBPASSWORD" />


DBNAME is what you specified as your database name in the control panel
DBUSERNAME is the username you created to connect to the database (and was associated with the database in the control panel)
DBPASSWORD is the password you associated with the username above

An example script:

<%@ Import Namespace="System.Data.SqlClient" %>
<%
Dim conn As SqlConnection
Dim sqlQuery As SqlCommand
Dim dtrTbl As SqlDataReader
conn = New SqlConnection( "Server=localhost\sqlexpress;uid=USERNAME;pwd=PASSWORD;database=DBID" )
conn.Open()
sqlQuery = New SqlCommand( "Select COLLUMN_NAME From TABLE_NAME", condDBID)
dtrTbl = sqlQuery.ExecuteReader()
While dtrTbl.Read()
Response.Write(“<li>" )
Response.Write(dtrTbl( "COLUMN_NAME" ) )
End While
dtrTbl.Close()
conn.Close()
%>

(167 vote(s))
Helpful
Not helpful

Comments (94)
28 April 2010 07:34 AM
these connectionstring does not work and shows up an error massage
please specify more support including fewer examples how we can connect to the database and how to confugure config file.

"Failed to generate a user instance of SQL Server due to failure in retrieving the user's local application data path. Please make sure the user has a local user profile on the computer. The connection will be closed."

Description: "An unhandled exception occurred during the execution of the current web request. Please review the stack trace for more information about the error and where it originated in the code."

Exception Details: "System.Data.SqlClient.SqlException: Failed to generate a user instance of SQL Server due to failure in retrieving the user's local application data path. Please make sure the user has a local user profile on the computer. The connection will be closed."

Source Error:
"An unhandled exception was generated during the execution of the current web request. Information regarding the origin and location of the exception can be identified using the exception stack trace below."

Regards
http://www.arpanet.ms

RESPONSE: The errors you are getting point at the fact that our connection string is not being used. You are trying to start a fully separate instance of MSSQL. Please contact our support to gain assistance.
Alex Ford
13 October 2010 11:29 PM
Is there a remote connection string I can use to connect to my database from another web application on a different site? Godaddy is horrible and does not allow remote access to their database. So if I can establish a connection from my web app running on my godaddy hosting account, then I can SELECT data from the database and INSERT over a separate connection.
15 October 2010 01:16 PM
The connection string is just an example. You can connect remotely so instead of using localhost or 127.0.0.1, you would use your domain name or the hostname of the server (or its ip address) to connect remotely.
Krassimir Boyanov
23 November 2010 04:28 PM
works fine for me. Thanks.
Paolo Montagna
08 January 2011 07:48 AM
works for me too thanks
Matt Altman
30 January 2011 11:49 AM
this worked for me. Thanks!
How do i know the host name of my database server
17 February 2011 10:45 AM
I have tried everthing written but all to no avail. Please Give me for more information
Arvand Sabetian
11 March 2011 03:00 AM
The hostname is your domain name if the domain is pointing to the server or SERVER.arvixe.com
Barrett
25 April 2012 09:44 AM
This should really be more clear. I don't know why the control panel doesn't create a connection string for you like godaddy does. This is terrible. You Arvixe's customer support told me that the host name was localhost... Obviously they don't know what they're talking about.
Themingware
24 February 2011 09:04 AM
I connect remotely via VS2010 and in the web.config without error using the server info and format below:

In VS2010:
ServerName = the catalog and other info is from the db you set up on the server.

In Web.config: (only a space between attribs)
<connectionStrings>
<add name="myConnName"
connectionString="Data Source=&quot;bamboo.arvixe.com &quot;;Initial Catalog=myDB;User ID=myID;Password=myPASWORD"
providerName="System.Data.SqlClient"/>
</connectionStrings>
For Membership Providers you can have something like:
<membership>
<providers>
<clear/>
<add name="AspNetSqlMembershipProvider"
type="System.Web.Security.SqlMembershipProvider"
connectionStringName="myConnName"
enablePasswordRetrieval="false"
enablePasswordReset="true"
requiresQuestionAndAnswer="false"
requiresUniqueEmail="true"
maxInvalidPasswordAttempts="5"
minRequiredPasswordLength="8"
minRequiredNonalphanumericCharacters="0"
passwordAttemptWindow="10"
applicationName="/" />
</providers>
</membership>

For Role Provider:
<profile>
<providers>
<clear/>
<add name="AspNetSqlProfileProvider"
type="System.Web.Profile.SqlProfileProvider"
connectionStringName="myConnName" applicationName="/" />
</providers>
</profile>

<roleManager enabled="true">
<providers>
<clear/>
<add name="AspNetSqlRoleProvider"
type="System.Web.Security.SqlRoleProvider"
connectionStringName="myConnName"
applicationName="/" />
<add name="AspNetWindowsTokenRoleProvider"
type="System.Web.Security.WindowsTokenRoleProvider"
applicationName="/" />
</providers>
</roleManager>
Paresh Dudhat
25 February 2011 12:14 PM
Its also works for me.. Thanks a lot friends....
Ariel Ferro
12 March 2011 06:05 PM
this doesn´t work for me. I don´t want to travel to the moon, really.. I´M SIMPLY TRING TO USE THE DEFAULT ASP NET MEMBERSHIP SYSTEM ON MY SITE
for example, this connection string:
<add name="ApplicationServices" connectionString="data source=.\SQLEXPRESS;Integrated Security=false;AttachDBFilename=|DataDirectory|aspnetdb.mdf;" providerName="System.Data.SqlClient"/>
drops this error:
Login failed for user ''.


please, i beg you to tell me WHICH CONNECTION STRING SHOULD I USE TO ACHIEVE THIS!!!!!
Arvand Sabetian
13 March 2011 03:02 AM
You are trying to attach a database which is not possible. You'll need to obtain a .bak file for your database and restore it through the control panel. Once you've done so, please then use one of the connection strings outlined in this KB with the proper database, username and password.
inga
16 March 2011 11:08 AM
Arvand,

All this guy wants is default membership feature. to do that needs to have an access "aspnet" database that contains all information about ASP.NET applications services. To achieve that:
1) create a new DB for him and run aspnet_regsql.exe on it (aspnet_regsql.exe -S DBServerName -U DBLogin -P DBPassword -A all -d DBName); This will create all tables and sp. Then give him the connection string;

2) Option 2 give him access to exsisting "aspnet" db and give him the connection string;

Ariel Ferro
-use code provide by Themingware with connection string that points to that new created DB by Arvand
Arvand Sabetian
20 March 2011 02:17 PM
I've tried #1 with several users and it hasn't worked for them. However, we're always willing to try things to make sure customers get their apps working exactly the way they want. Ariel, I would suggest opening up a support ticket and then email qa .at. arvixe.com with your ticket information.
Dan Lipsit
28 March 2014 11:36 AM
not sure if anyone posted this yet but for aspnet membership provider just run aspnet_regsql.exe locally on your machine. Then from the GUI you can point it at your DB.

For getting the connection string, it is super easy. Just create a new data connection through server explorer in Visual Studio and connect to your db using the same credentials as you do through SSMS. Then, right click on your data connection and select properties. The connection string is right there, just copy and paste it into your web.config (obviously replacing the **** for password with your actual password)
Mark Bennion
20 March 2011 07:46 PM
I am a brand new customer of Arvixe (and very happy to be one). I have received so much help from various forums, it is time for me to contribute. I have been struggling with the exact same problems and finally resolved them.
Inga is correct about #1, but the successful approach I used was to do it on my local machine, use SQL Server Management Studio to back up the database, upload the backup to my website, and restore it using the Restore from the Control Panel. I struggled with the connection string (quite a bit of time because I was misspelling arvixe), but finally got it working following Themingware's advice. Thanks to Arvand, Themingware, and Inga. Arvixe is the greatest!!!
Dan Szabo
02 April 2011 01:29 AM
Just wanted to thank Ariel. His solution #1 worked perfectly for me.

I'm running asp.net 4.0, aspnetdb.mdf membership db.
quang pham
09 April 2011 09:51 PM
I am able to query my data in the my database but not can not insert data to my table. It does not give me any error message. Could someone help me about it?
Arvand Sabetian
11 April 2011 03:31 AM
In that case, I would be a 100% sure its not a connection string issue and coding issue. If you can query your database, you should be able to insert and if there is a database error, you would get an error. Therefore, I suggest looking over your code again.
Anirudh Ramchandran
23 May 2011 02:28 AM
Is there a way to connect to SQL2008 using visual basic 6.0 - I have an old application and do not want to shift it to vs.net

I tried this but did not work -

Conn="Provider=SQLOLEDB; Data source=websitename; UID=db_username; PWD=db_password; database=database_name;"

Arvand Sabetian
02 June 2011 11:13 PM
I would suggest posting this on our forum or support as we need the error and we may have the error explained here in the KB or on our blog/forum.
surendra
07 June 2011 10:17 PM
Hi.. Anirudh
use Provider name "SQLNCLI10" instead of "SQLOLEDB"
Elizabeth Gee
20 June 2011 01:50 PM
I just joined arvixe yesterday, and have managed to do a .BAK restore of my SQL Server 2008 database. Now I need help with the connectionString in my web.config. I read through this blog, and am still lost. I joined arvixe to try uploading an ASP.Net MVC3 project. Here is my connection string that works on my local machine:
<add name="ProductEntities" connectionString="metadata=res://*/Models.ProductDataModel.csdl|res://*/Models.ProductDataModel.ssdl|res://*/Models.ProductDataModel.msl;provider=System.Data.SqlClient;provider connection string=&quot;data source=.\SQLEXPRESS;attachdbfilename=|DataDirectory|\Products.mdf;integrated security=True;user instance=True;multipleactiveresultsets=True;App=EntityFramework&quot;" providerName="System.Data.EntityClient" />

I tried substituting the data source:
<add name="ProductEntities" connectionString="metadata=res://*/Models.ProductDataModel.csdl|res://*/Models.ProductDataModel.ssdl|res://*/Models.ProductDataModel.msl;provider=System.Data.SqlClient;provider connection string=&quot;data source=MyDomain.com.strawberry.arvixe.com;attachdbfilename=|DataDirectory|\Products.mdf;integrated security=True;user instance=True;multipleactiveresultsets=True;App=EntityFramework&quot;" providerName="System.Data.EntityClient" />

I am not sure what the connection string needs to be for Entity Framework and MVC 3 on Arvixe.
Arvand Sabetian
24 June 2011 04:35 AM
Per the above example, you should be using Initial Catalog=DBNAME;Integrated Security=false;User ID=DBUSERNAME;Password=DBPASSWORD instead of attachdbfilename=|DataDirectory|\Products.mdf;
Elizabeth Gee
06 July 2011 07:49 PM
I get this error when I try this connectionString:
Failed to generate a user instance of SQL Server due to failure in retrieving the user's local application data path. Please make sure the user has a local user profile on the computer. The connection will be closed.
[EntityException: The underlying provider failed on Open.]

http://icontoo.com.strawberry.arvixe.com/ click on Products or Categories

<add name="ProductEntities" connectionString="metadata=res://*/Models.ProductDataModel.csdl|res://*/Models.ProductDataModel.ssdl|res://*/Models.ProductDataModel.msl;provider=System.Data.SqlClient;provider connection string=&quot;data source=localhost\SQLEXPRESS;Initial Catalog=Products;integrated security=true;User ID=myDBusername;Password=myDBuserpassword;user instance=True;multipleactiveresultsets=False;App=EntityFramework&quot;" providerName="System.Data.EntityClient" />
Arvand Sabetian
07 July 2011 05:21 PM
It appears that your application is not using the data source that you've mentioned in the comment. The error you've encounter is generally seen when your application is attempting to attach a mdf file to the application or create a new one.
Daniel Bradish
13 July 2011 06:31 AM
I struggled as well getting my MVC 3 application to connect to the database, but I did get it working. Here's the connection string I used. You do have to tweak the one generated by the framework:

<add name="PalMateOnlineEntities" connectionString="metadata=res://*/Models.PalMateOnline.csdl|res://*/Models.PalMateOnline.ssdl|res://*/Models.PalMateOnline.msl;provider=System.Data.SqlClient;provider connection string=&quot;data source=localhost\SQLEXPRESS;initial catalog=DBNAME;Integrated Security=false;User ID=USER;Password=PASSWORD;multipleactiveresultsets=True;App=EntityFramework&quot;" providerName="System.Data.EntityClient" />

Good luck!
Bhoy
19 July 2011 06:03 AM
dear arvixe, I have the same problem with. i got a server error after I uploaded my site. I inquired before i got a hosting plan from you and I was informed that .MDF file will work directly without any changes. That's the reason why I got your hosting plan. So please dont give me an email saying refer to this site. I want my site as is. so please help me. make my .MDF file work. thank you
Arvand Sabetian
25 July 2011 09:03 AM
You can not directly connect to a mdf file. You must backup your databases locally to a .bak file and restore on our side.
Robert O'Bannon
20 July 2011 03:38 PM
Can I connect to the database from my WinForm VB application?
Arvand Sabetian
25 July 2011 09:03 AM
It should be the same process as outlined here.
bhoy tn
21 July 2011 12:46 AM
does not work for my site.
Arvand Sabetian
25 July 2011 09:03 AM
Please provide proper errors and urls to our support staff so that we can assist you.
Hennie
08 September 2011 06:12 AM
I am new to arvixe and db hosting. I've also struggled to connect to my db but in the end managed to solve my problem self.

I believe some of the solutions above is good but did not help me much.
Here is the string that I am using and works good. Perhaps it can help others to.

<add name="TestDB.MySettings.ConnectionString" connectionString="Provider=SQLOLEDB;Data Source=focus1968.com,1433;persist Security=False;Initial Catalog=DBName;User ID=MyUser;Password=password"
providerName="System.Data.OleDb" />

I'v add ,1433 (sqlport) to my domain name and change from Integrated Security=false to persist security=false.
Edog
17 October 2011 12:20 PM
You guys rock! Excellent service. Glad I found you guys.
Michael Carr
26 March 2012 05:50 PM
Thanks, positive feedback is always appreciated.
john giacalone
18 March 2012 09:33 PM
This is the connection string I used for my app...

<add name="DataContext" connectionString="Data Source=windflower.arvixe.com,1433;Initial Catalog=DBNAME;Persist Security Info=false;Integrated Security=false;User ID=ForJandS;Password=password" providerName="System.Data.SqlClient"/>

Note: I did have tons of issues at first using Entity Framework, because there were DB permission issues...The issue was on the creation of the tables...make sure when viewing the table it says dbo.TableName and not user.TableName.

If you right click in MS SQL management studio and add a table, it will be created as user.TableName!!! and this causes all kinds of issues with entity framework and stored procedures.

IE: CREATE TABLE [dbo].[TableName] vs CREATE TABLE [USER].[TableName].... that was the difference!
Sebastian Kade
11 August 2012 06:04 PM
Adding [ServerName],1433 worked for me.

e.g. nettle.arvixe.com,1433
Michael Carr
14 August 2012 03:21 PM
Thanks for the comment.
Elana
22 March 2012 02:29 AM
I just joined Arvixe yesterday. I installed my site, it works, but when I try to connect to the database I get an error message:
System.Data.SqlClient.SqlException: Cannot open database "TestDB" requested by the login. The login failed.
Login failed for user 'TestUser'.

I am using the same connection string as Arvand suggested:
Data Source=localhost\sqlexpress;Initial Catalog=TestDB;Integrated Security=false;User ID=TestUser;Password=password

Can there be some kind of security setting for my DB that I could change in the control panel? Or any other advice?

Some points that might be related to the problem: when I am trying to connect to the DB through SSMS, I get to the point where I see the list of databases, but when I want to access my DB, I get a message The database is not accessible.

Also, I created a .bak file for my DB, but could not Restore it in control panel. I had to call the support, FTP the file and they restored it for me.

My site is built in VS2010. I disabled firewall for now.
Elana
22 March 2012 02:36 AM
I think I just figured it out. There is a checkbox next to the username in the control panel and it was not ticked. Once I ticked it I could log in :-)
Michael Carr
26 March 2012 05:53 PM
Yes that is correct. The check box is granting access for that database user to connect to that specific database. Any database user that you create will need to have this set for each database that you would like them to have access to.
Xan Chin Xao Ju
16 April 2012 03:10 AM
IT DOESN'T WORK! my connection string is correct but...

A network-related or instance-specific error occurred while establishing a connection to SQL Server. The server was not found or was not accessible. Verify that the instance name is correct and that SQL Server is configured to allow remote connections. (provider: Named Pipes Provider, error: 40 - Could not open a connection to SQL Server)
Michael Carr
12 May 2012 06:03 PM
You have an error in the connection string, it sounds like the server name is not correct. If the script is running on the local server you can try using localhost or 127.0.0.1 for the server name
Joe Kauffman
19 April 2012 10:07 PM
The DBNAME part of the string...is that the name I created for the database or the Logical Name shown as db3*******?
Michael Carr
12 May 2012 06:04 PM
That would be the actual name of the database you have created that you are wanting to connect to.
Mohamad Ahmad
25 May 2012 02:45 PM
please this is my website : www.albusscamp.com and i upload all my files to it and i have already created a data base called AljalilConn and i have created a connection string <add name="AljalilConn" connectionString="Data Source=.localhost\SQLEXPRESS;AttachDbFilename=|DataDirectory|localhost\Database.mdf;Initial Catalog=AljalilConn;Integrated Security=True;User Instance=True User ID=aljali5 ;Password=*****" providerName="System.Data.SqlClient"/> so please correct it if there are any problem in this code becose my website dont want to open
Michael Carr
27 September 2012 10:20 AM
I would recommend opening a support ticket so we can investigate in real time.
Adam Kotkowski
22 July 2012 01:51 PM
Please help. I cannot get this to work at all. I am using MVC3 (Razor) and the entity framework. This is my connection string:

<connectionStrings>
<add name="WhimsicalFurnishingEntities"
connectionString="metadata=res://*/App_Code.WhimsicalFurnishingModel.csdl|res://*/App_Code.WhimsicalFurnishingModel.ssdl|res://*/App_Code.WhimsicalFurnishingModel.msl;
provider=System.Data.SqlClient;
provider connection string=
'data source=localhost\sqlexpress;
Initial Catalog=DB;
integrated security=True;
User ID=USERNAME;
Password=PASS;
Connection Timeout=60
user instance=True;
multipleactiveresultsets=True;
App=EntityFramework'"
providerName="System.Data.EntityClient" />
<add name="WhimsicalFurnishingConnectionString" connectionString="Data Source=localhost\sqlexpress;Initial Catalog=DBNAME;Integrated Security=true;User ID=USERNAME;Password=PASS;User Instance=True" providerName="System.Data.SqlClient"/>
</connectionStrings>

I get the following error:
Unable to find the requested .Net Framework Data Provider. It may not be installed.
Michael Carr
04 September 2012 11:44 AM
Please open a support ticket for help with this or any other connection string issues. We will have to do some troubleshooting on that and need more specifics regarding the account.
Jeremy Janes
30 July 2012 09:40 AM
I've tried nearly every connection string imaginable, including those listed above. I currently have this is in place, as it gives me the least amount of headache:

Data Source=localhost\sqlexpress;Initial Catalog=vp1;Integrated Security=false;User ID=userid;Password=password

I'm trying to install nopCommerce 2.5. and this seems to create the database, but not allow me access. I get the following error:

Setup failed: System.Exception: Database does not exist or you don't have permissions to connect to it at Nop.Web.Controllers.InstallController.Index(InstallModel model)

The database does exist--its there in all its glory. I just can't get the credentials to work it seems. Were talking MVC 3.0 and ASP.Net 4.0.

Any other options?
Michael Carr
01 August 2012 11:08 AM
In the control panel, you must also ensure that the database user you have created, has been granted access to the database itself. assuming the username and password are correct in your connection string, that is the next thing I would check.
Jeremy Janes
30 July 2012 09:49 AM
Oh, Goody. Now we are getting somewhere. Made a quick tweak to things based on suggestions on the nopCommerce boards and get the following error:

"We're sorry, an internal error occurred that prevents the request to complete.

Our supporting staff has been notified with this error and will address this issue shortly. We profusely apologize for the inconvenience and for any damage this may cause. You might want to try the same action at later time."

Connection string now looks like this:

DataProvider: .\sqlexpress
DataConnectionString: Data Source=localhost;Initial Catalog=vp1;Integrated Security=false;User ID=userid;Password=password
Michael Carr
01 August 2012 11:05 AM
The error sounds like a 500, and is usually not related to the connection string. Seems you have corrected one error to locate another. You can try enabling detailed error logs from the control panel and get more specifics. The option is located under web > websites > domain name > error tab
Himalaya Garg
28 August 2012 12:30 AM
I am getting below error:

A network-related or instance-specific error occurred while establishing a connection to SQL Server. The server was not found or was not accessible. Verify that the instance name is correct and that SQL Server is configured to allow remote connections. (provider: TCP Provider, error: 0 - No such host is known.)


My string is:
<add name="myConnectionString" connectionString="Data Source=codeparallel.arvixe.com,1433;Initial Catalog=MYDB;Integrated Security=false;User ID=MYUSERID;Password=MYUSERPWD" providerName="System.Data.SqlClient" />

So frustrated, working on this since yesterday. Please tell me where I am wrong...???????
Michael Carr
04 September 2012 10:27 AM
The Data Source does not sound correct, instead of codeparallel.arvixe.com try using your actual domain name, the server name, or if the script is running locally on the server, use "localhost" or the IP "127.0.0.1"
Ryan
06 September 2012 06:32 PM
Hey, just wanted to say that MS SQL works perfectly on multiple domains/applications, never had issues. Thought it might be refreshing in the midst of an exhausting amount of negative comments.
Michael Carr
25 September 2012 12:47 PM
Thanks for your feedback
Gkaintatzis Panayiotis
14 September 2012 01:23 AM
I spent the two last days trying to figure out how the connection string should look like to connect remotely .. i just found the solution for me so here it is :

<connectionStrings>
<clear/>
<remove name="LocalSqlServer"/>
<add name="LocalSqlServer" connectionString="Data Source=serverName.arvixe.com;Initial Catalog=DBname;User ID=yourUsername;Password=yourPassword;" providerName="System.Data.SqlClient"/>
</connectionStrings>
Michael Carr
25 September 2012 12:47 PM
Thank you for sharing
John Bencina
29 September 2012 09:55 PM
Is it possible to user Integrated Security to allow the site to connect to the database without storing the password in plaintext?

Arvixe already has a setting for Dedicated Application Pool in the control panel. If I understand its function correctly, then every website will have a unique application pool. It is possible then to add the IISAPPPOOL\POOL_NAME to the database logins. This would securely give your website access to the database without ever storing a password in plaintext
Michael Carr
01 October 2012 11:28 AM
Every site has a dedicated application pool but we do not allow integrated logins for database connectivity. They have to use SQL login
Juan Espinosa
12 October 2012 02:36 PM
Hi, I need help to setup my connections strings correctly this is what I have
on my localhost

<add name="strConn" connectionString="Data Source=localhost\SQLEXPRESS_2008;AttachDbFilename=|DataDirectory|\ASPNETDB.MDF;Integrated Security=True; Catalog=ASPNETDB.MDF;User Instance=True" providerName="System.Data.SqlClient" />

I uploaded my *.MDF & *.ldf files using websitepanel

someone for support told me that I don't need a .bak file he said that I have to create the db from the website panel then he attached this to the DB but it is not working Please help to solve this issue.
Michael Carr
19 October 2012 03:02 PM
Our support should be able to restore your database backlup for you. Simply supply the backup files that you have and we will be glad to assist.
nimo
03 November 2012 06:22 PM
hello,
I have been trying since a long time to upload my db to the SQL server 2008 hosting, but I can't do it. UI have tried to make a .bak and then restore it to the server and I am still facing problem to restore it.
I guess the web.com fig hacve nothing to do with the upload of the .bak file to the server. But what am I supposed to do before I Upload my .bak to the server?
Michael Carr
06 November 2012 06:34 PM
You can restore your .bak file directly from the control panel. Our staff can also do this for you, if you would like you can upload the .bak to your account using the file manager and have a member of support restore it to any database that you would like.
Marcus Ford
04 December 2012 12:39 AM
For deployment purposes in Visual studio, you can add a web config transform file which will create a web config.debug file and a web config.release file. By right clicking on the current web config file in your Visual Studio project, select Add Config Transforms. If you are using the web config.release file then use the Active(Release) configuration in the Package/Publish SQL tab. This will add the web config.release file into Arvixe's server without changing the old web config file and without adding the web config file to their server. In the web config.release file you can add <connectionStrings>
<add name="YourConnectionString" connectionString="Data Source=servername.arvixe.com;Initial Catalog=YourDatabse;User ID=YourUserID;Password=YourPassword"
providerName="System.Data.SqlClient" xdt:Transform="SetAttributes" xdt:Locator="Match(name)"/>
</connectionStrings> Under Package/Publish SQL Settings which is under My Projects, you can click on Import from Web.config to upload the source database connection string. In the Connection String for destination Database you can use the connection string in the web config.release file. Under Package/Publish Web settings, select "include only files needed to run this application" and choose exclude App_Data folder. Click on the Project tab in the menu bar and select Build Deployment package. Then click on the build tab on the menu bar and Select Publish "Your Website". For the publish method select FTP and the target location is ftp://ftp.yourdomainname.com. Select passive mode and enter your User name and password for your domain. Then click Publish.
Michael Carr
17 April 2013 09:27 AM
Thanks for your comments
Ivan Reyna
22 March 2013 06:19 PM
I didn't have to modify the web.config.

For SQL Server 2012, in my code I wrote:

set con = Server.CreateObject("ADODB.Connection")
set rs = Server.CreateObject("ADODB.Recordset")
connection = "Provider=SQLOLEDB;Data Source=localhost;UID=uid;PWD=pwd;database=yourDBid"
con.ConnectionString = connect
Michael Carr
17 April 2013 09:27 AM
Thanks for providing that sample.
Eric Dyson
02 April 2013 12:30 PM
Can I not use this to connect to my access db? Provider=Microsoft.Jet.OLEDB.4.0;Data Source=" & Server.MapPath("/data/mydb.mdb"). Why does this have to be so difficult all the time?
Michael Carr
17 April 2013 09:31 AM
I would try using the full server path instead of Server.MapPath("/data/mydb.mdb"), also you may find our article on access helpful :

https://support.arvixe.com/index.php?/Knowledgebase/Article/View/75/11/how-to-connect-to-a-ms-access-database-from-an-asp-script
shubhanshu gupta
19 June 2013 11:11 PM
i got error no 40..when i connect my website to hosting sql server. It is running on local server very nicely..
I m using this connection string.
<connectionStrings>
<add name="constr" connectionString="Data Source=shubhanshu00.db.11294331.hostedresource.com; Initial Catalog=shubhanshu00; User ID=shubhanshu00; Password=******" providerName="system.data.sqlclient"/>
</connectionStrings>

pls help me sir.... It is very urgent...
thank you sir
Michael Carr
03 July 2013 03:27 PM
Your connections are being made to a remote server, at hostedresource.com. you need to copy your SQL data to the local server, and then adjust your connection string to connect to the local server.
philip yasger
29 June 2013 06:42 AM
trying to connect the website to the database...

<?xml version="1.0"?>

<!--
For more information on how to configure your ASP.NET application, please visit
http://go.microsoft.com/fwlink/?LinkId=169433
-->

<configuration>
<connectionStrings>
<Server=violet.arvixe.com;Database=elogin;User Id=elogin;Password=123456;>
</Server>
</connectionStrings>
<system.web>
<authentication mode="Forms" />
<authorization>
<allow roles="Administrators" />
</authorization>
<roleManager enabled="true" />
<compilation debug="true" strict="false" explicit="true" targetFramework="4.0" />
</system.web>

<system.web>
<customErrors mode="Off"/>
</system.web>
</configuration>
Michael Carr
16 July 2013 01:23 PM
The solution depends greatly on the connection error you are getting. If would start by changing the server name to 127.0.0.1. If that doesnt help please create support ticket with the connection error and I am sure we can get it fixed for you.
Noman Ashraf
05 July 2013 07:50 AM
Please help...
Server=199.48.254.186;Initial Catalog=filesseaddatabase;User ID=*******;Password=******

this connection string not work....
Error:-
Failed to generate a user instance of SQL Server due to failure in retrieving the user's local application data path. Please make sure the user has a local user profile on the computer. The connection will be closed.



Michael Carr
05 July 2013 12:50 PM
Please create a support ticket.
Nino Hilot Lumagod
08 August 2013 11:26 PM
Hello Sir/Maam..i have a problem in my project of my boss. My problem is how to save/retrieve image in localhost using sql database?..Help me please ,that my problem. I'm using visual basic 2008, in my sql database is in the localhost. Can u help my problem? There's any one knows?
Thanks. Just email my account in helping me.
Michael Carr
14 August 2013 10:22 AM
You can create backup files of your databases from the website control panel. We can also aid you in doing this if you need help. Simply contact us via any of our support methods, chat, phone or email.
Bekenty
10 August 2013 06:43 PM
You should be able to use this connection string in the MVC application.
<add name="YOURDBContext" connectionString="Data Source=YOUR SERVERNAME;Initial Catalog=DATABASENAME;User Id=YOUR DATABASE USER; Password=XXXXXX;Integrated Security=False" providerName="System.Data.SqlClient" />
Michael Carr
14 August 2013 10:21 AM
Thanks for the comment
Sarfraz Alam
16 September 2013 09:49 AM
this is my connection string: <add name="NewLedger.Properties.Settings.Database1ConnectionString"
connectionString="Data Source=(LocalDB)\v11.0;AttachDbFilename=|DataDirectory|\bin\Debug\DB.mdf;Integrated Security=True;Connect Timeout=30"
providerName="System.Data.SqlClient" />
but after deployment its not work plz help in solving the problem. thanks
Michael Carr
17 September 2013 11:19 AM
Please create a support ticket.
NotMyUsername
02 October 2013 04:14 PM
If you are having trouble using the entity framework for MVC, this worked for me:

- I was able to create a new user, but whenever I tried to access my database, I was getting the error: "An error occurred while attempting to initialize a System.Data.SqlClient.SqlConnection object. The value that was provided for the connection string may be wrong, or it may contain an invalid syntax.\r\nParameter name: connectionString"

- For some reason, using 2 connection strings fixed it. The role provider, profile provider, and membership provider all reference a connection string that is in this format: <add name="ConnectionName" connectionString="data source=yourservername.arvixe.com;initial catalog=yourdbname;user id=yourusername;password=yourpassword;Integrated Security=False" providerName="System.Data.SqlClient" />

- Then, whenever creating an entity context in a controller, this string is passed through as a parameter (note: this is just a slight modification to the auto-generated string): <add name="AnotherConnectionString" connectionString="metadata=res://*/yourdatabase.csdl|res://*/yourdatabase.ssdl|res://*/yourdatabase.msl;provider=System.Data.SqlClient;provider connection string='data source=yourservername.arvixe.com; initial catalog=yourdatabase;user id=yourusername;password=yourpassword;Integrated Security=False'" providerName="System.Data.EntityClient" />

And I haven't had an issue since. If anyone could let me know why this even works I'd appreciate it. But, it appears to work for both debugging locally and publishing.
Elliott Brown
23 March 2014 10:51 AM
I finally found how to get Profile providers working with the default database.

You basically have to take a backup of the local database, and then modify the profile providers as follows:

<providers>

<clear/>
<add name="AspNetSqlProfileProvider"
type="System.Web.Profile.SqlProfileProvider"
connectionStringName="DefaultConnection" applicationName="/" />

</providers>

Basically the same thing as the other forms, however you need to take a backup of your local database and restore it to the remote database. Otherwise the functions and stuff will not transfer to the remote database. I'll be writing a quick guide on this a bit later.

Thanks,
EBrown
Michael Carr
25 March 2014 12:24 PM
Thanks for the comment
Charles Custer
26 May 2014 11:29 AM
Hi All, I have ready many posts here, but I cannot connect. I can connect via SSMS, but not with my connectionstring via MVC app. (I was able to connect to my local, but not Arvixe remotely.

My connection string
<connectionStrings>
<add name="MyContext" connectionString="Data Source=crawfoot.arvixe.com;Initial Catalog=BumperMedic;User ID=myUserId;Password=MyPassword" providerName="System.Data.SqlClient" />
</connectionStrings>

My Error:

{"An error occurred while getting provider information from the database. This can be caused by Entity Framework using an incorrect connection string. Check the inner exceptions for details and ensure that the connection string is correct."}

Inner:{"The provider did not return a ProviderManifestToken string."}

{"A network-related or instance-specific error occurred while establishing a connection to SQL Server. The server was not found or was not accessible. Verify that the instance name is correct and that SQL Server is configured to allow remote connections. (provider: Named Pipes Provider, error: 40 - Could not open a connection to SQL Server)"}

{"The network path was not found"}

Please help.
Michael Carr
29 May 2014 11:50 AM
Normally it is due to a bad username or password, ensure user id= the user for the database and you have granted that user access rights to the database. A common mistake is to insert your account username in that place. If you are unable to resolve the problem please open a support ticket so we can see the exact specifics of your connection string.
Marco
09 September 2014 04:13 PM
Which way should configure the conection string for access with entity framework 6.0.0 ? my plan is PersonalClass ASP.
Michael Carr
19 September 2014 01:54 PM
Microsoft has some good guides on this. Start with this one : http://msdn.microsoft.com/en-us/data/jj556606.aspx
Kailas Visapure
24 September 2014 09:49 AM
Is this error because of Connection String :

A network-related or instance-specific error occurred while establishing a connection to SQL Server. The server was not found or was not accessible. Verify that the instance name is correct and that SQL Server is configured to allow remote connections. (provider: SQL Network Interfaces, error: 26 - Error Locating Server/Instance Specified)
Michael Carr
08 October 2014 12:50 PM
Yes, from your error it sounds like the data source is not correct.
Post a new comment
 
 
Full Name:
Email:
Comments:
CAPTCHA Verification 
 
Please enter the text you see in the image into the textbox below (we use this to prevent automated submissions).