I develop a website and there are two databases in my web site.
I made two database and users in plesk panel and upload the back ups,
database the first name is database_Journal and database name 2 is database_General and also the users are UserID1 and UserID.
But there is some thing wrong in it and it gave me this 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: Named
Pipes Provider, error: 40 - Could not open a connection to SQL Server)
My web config is like this:
<add name="dbconn" connectionString="Password==******;; Persist Security Info=True;User ID=UserID1; Initial Catalog=database_General; Data Source=***.**.**.**" providerName="System.Data.SqlClient" />
<remove name="LocalSqlServer"/>
<add name="LocalSqlServer" connectionString="Password=******;Persist Security Info=True;User ID=UserID1; Initial Catalog=database_General; Data Source=***.**.**.**" providerName="System.Data.SqlClient" />
<add name="dbconn_general" connectionString="Password==******;; Persist Security Info=True;User ID=UserID; Initial Catalog=database_Journal; Data Source=***.**.**.**" providerName="System.Data.SqlClient" />
Try this format...
<add name="dbconn" connectionString="server=YourServerNameOrServerIpAddress; database=database_General; uid=UserID1; Password=******" providerName="System.Data.SqlClient" />
Related
I have IIS and SQL Server Express on the same machine. After deployment of web site to this environment I get this error:
Cannot open database "MyDB" requested by the login. The login failed.
Login failed for user 'IIS APPPOOL\USER'.
Here are my connection strings where I set SQL Server user
<connectionStrings>
<add name="myCS1"
connectionString="data source=172.20.3.20\SQLEXPRESS;initial catalog=MyDB;user id=SomeUser;password=SomeUser###;integrated security=True;MultipleActiveResultSets=True;"
providerName="System.Data.SqlClient" />
<add name="myCS2"
connectionString="metadata=res://*/CLModel.csdl|res://*/CLModel.ssdl|res://*/CLModel.msl;provider=System.Data.SqlClient;provider connection string="data source=172.20.3.20\SQLEXPRESS;initial catalog=myDB;persist security info=True;user id=SomeUser;password=SomeUser###;MultipleActiveResultSets=True;App=EntityFramework""
providerName="System.Data.EntityClient" />
</connectionStrings>
I want to use SQL Server user for connection to the database but not AppPool user.
I specified login and password but it seems that this info is not taken in account and in error message I still see IIS user but not sql.
What I missed?
Well, you specify both - explicit user id and password, and Integrated Security=True - in your myCS1 connection string:
data source=172.20.3.20\SQLEXPRESS;initial catalog=MyDB;
user id=SomeUser;password=SomeUser###;integrated security=True;
In this case, the integrated security wins over your user - you need to specify only the user id and password and get rid of the integrated security - so use this:
<connectionStrings>
<add name="myCS1"
connectionString="data source=172.20.3.20\SQLEXPRESS;initial catalog=MyDB;user id=SomeUser;password=SomeUser###;MultipleActiveResultSets=True;"
providerName="System.Data.SqlClient" />
<add name="myCS2"
connectionString="metadata=res://*/CLModel.csdl|res://*/CLModel.ssdl|res://*/CLModel.msl;provider=System.Data.SqlClient;provider connection string="data source=172.20.3.20\SQLEXPRESS;initial catalog=myDB;persist security info=True;user id=SomeUser;password=SomeUser###;MultipleActiveResultSets=True;App=EntityFramework""
providerName="System.Data.EntityClient" />
</connectionStrings>
I am deploying an ASP.NET web app to Azure Web Sites.
The site uses Entity Framework, and when I include the following in Web.config it runs fine:
<connectionStrings>
<add name="DataContext" connectionString="metadata=res://*/Models.WpsData.csdl|res://*/Models.WpsData.ssdl|res://*/Models.WpsData.msl;provider=System.Data.SqlClient;provider connection string="data source=XXXX;initial catalog=XXXX;persist security info=True;user id=XXXX;password=XXXX;multipleactiveresultsets=True;application name=EntityFramework"" providerName="System.Data.EntityClient" />
</connectionStrings>
However, if this connection string is removed and instead specified via the Azure Management Portal, an error occurs.
Name: DataContext
Value: metadata=res://*/Models.WpsData.csdl|res://*/Models.WpsData.ssdl|res://*/Models.WpsData.msl;provider=System.Data.SqlClient;provider connection string="data source=XXXX;initial catalog=XXXX;persist security info=True;user id=XXXX;password=XXXX;multipleactiveresultsets=True;application name=EntityFramework"
Type: Custom
This results in the error: No connection string named 'DataContext' could be found in the application config file.
See similar question here.
Try leaving the connection string in web.config with some value (either some test connection string, or some dummy value) e.g.
<connectionStrings>
<add name="DataContext" connectionString="dummy" providerName="System.Data.EntityClient" />
</connectionStrings>
I have a very complex data structure within a web application that im working on, which requires 3 connections at once to a MSSQL database, id rather not but its the only way to achieve what is required for now.
I set my connectionstrings in web.config as such:
<connectionStrings>
<add name="Foo_mainConnectionString1" connectionString="Data Source=GDE-WK-003\SQLEXPRESS;Initial Catalog=Foo_main;Integrated Security=True" providerName="System.Data.SqlClient" />
<add name="Foo_mainConnectionString2" connectionString="Data Source=GDE-WK-003\SQLEXPRESS;Initial Catalog=Foo_main;Integrated Security=True" providerName="System.Data.SqlClient" />
<add name="Foo_mainConnectionString3" connectionString="Data Source=GDE-WK-003\SQLEXPRESS;Initial Catalog=Another_FOO;Integrated Security=True" providerName="System.Data.SqlClient" />
</connectionStrings>
When set up as above (2 connections to the same DB) it works fine (although the third ' Another_FOO' is an unused one from a discontinued part of the project.
So in order to get another connection established, i changed "Another_FOO" to "Foo_Main"
Giving me 3 connections to the same DB.
On trying to run the website, it now seems that none of the connections are established.
Any ideas why this might be? Is there likely to be a connection limit that i cant find?
This question already has answers here:
Closed 12 years ago.
Possible Duplicate:
A network-related or instance-specific error occurred while establishing a connection to SQL Server.
Today i have create two pages login.aspx using LOgin control and register.aspx using Create user wizard ...
when i use connection string of my production server in my local computer then site works only if my database ASPNETDB.MDF is present in APP_Data Folder in my local computer..
if i rename ASPNETDB.MDF or Delete ASPNETDB.MDF from my local compuet App_Data the the following error occurs ...
An attempt to attach an auto-named database for file C:\Users\Ashish Dobriyal\Documents\Visual Studio 2008\WebSites\VOLVOO\App_Data\ASPNETDB.MDF failed. A database with the same name exists, or specified file cannot be opened, or it is located on UNC share.
but
After i publish my webpages ..... and database to my production server .... it produces an 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: SQL Network Interfaces, error: 26 - Error Locating Server/Instance Specified)
What was the problem actually ... ??
MY PRODUCTION SERVER CONNECTION STRING :
<connectionStrings>
<remove name="ConnectionString"/>
<add name="ConnectionString" connectionString="workstation id=volvobusesindia.mssql.somee.com;packet size=4096;user id=username;pwd=password;data source=dobriyal.mssql.somee.com;persist security info=False;initial catalog=dobriyal" providerName="System.Data.SqlClient"/>
</connectionStrings>
MY LOCAL SERVER CONNECTION STRING :
<connectionStrings>
<add name="ConnectionString" connectionString="Data Source=.\SQLEXPRESS;AttachDbFilename=|DataDirectory|\ASPNETDB.MDF;Integrated Security=True;User Instance=True" providerName="System.Data.SqlClient"/>
</connectionStrings>
when i use connection string of my
production server in my local computer
then site works only if my database
ASPNETDB.MDF is present in APP_Data
Folder in my local computer..
This is because you need to add access permissions to the directory that you going to put the database. The permissions must be for the user that runs the asp.net pool that you using.
Alternative try this string, for both production and local server and just be sure that your database have the correct permissions for been access from the asp.net running pool account.
This is not depended from what you write on the string but from how you correctly setup the database. Its working 100% so if not play for you search the database permissions, both file and database settings.
<connectionStrings>
<add name="ConnectionString" connectionString="Data Source=localhost;Initial Catalog=dobriyal;Integrated Security=True;" providerName="System.Data.SqlClient" />
</connectionStrings>
hi im trying to get a dataset from an access database
im using this connection string:
<connectionStrings>
<add name="SiteConnString" connectionString="Data Source=c:\inetpub\vhosts\db\mainDB.mdb"
providerName="Microsoft.Jet.OLEDB.4.0" />
</connectionStrings>
and this is my call to SqlHelper:
myDataSet = SqlHelper.ExecuteDataset(connString, CommandType.Text, strSQL);
and the error im getting is this:
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)
The providerName attribute expects an ADO.NET provider class name. Try changing your connection like so:
<connectionStrings>
<add name="SiteConnString"
connectionString="Provider=Microsoft.Jet.OLEDB.4.0;Data Source=c:\inetpub\vhosts\db\mainDB.mdb"
providerName="System.Data.OleDb" />
</connectionStrings>
A very handy reference for connection string formats is http://connectionstrings.com