https sql server connection - asp.net

I have a application using SQL Server 2008, the connectionstring works fine without https. However, when try to use https I get an error. I'm using the below string, am I supposed to add something else instead?
<add name="MyConnectionString" connectionString="Data Source=https://ServerName\QA01;Initial Catalog=DB_QA;Uid=abc;Pwd=xyz" providerName="System.Data.SqlClient" />
the only thing i did was add a https:// infront of the servername. it works fine without it, the db team told me SSL is setup on the db server.
I get the following 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.

SQL Server does not connect via HTTP, and not via HTTPS as well. In other words, you are using the wrong syntax here.
Have you enabled SSL encryption for your SQL Server? This link tells you how its done: How to enable SSL encryption for an instance of SQL Server by using Microsoft Management Console
Then, you use the Encrypt statement in the connection string:
Using Encrypt=yes in a Sql Server connection string -> "provider: SSL Provider, error: 0 - The certificate's CN name does not match the passed value."

Related

Connecting SQL Server database to ASP.NET application release

I have an ASP.NET application using Entity Framework. I'm trying to release it on the hosting, but I get following errors:
[Win32Exception (0x80004005): The system cannot find the file specified]
[SqlException (0x80131904): 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: 52 - Unable to locate a Local Database Runtime installation. Verify that SQL Server Express is properly installed and that the Local Database Runtime feature is enabled.)]
I set the connection string as shown on the hosting website and created database. How should I configure this to get rid of this error?
Exception due to your web application is not able to connect SQLSERVER instance. Following are options to resolve the problem:
Check if your service is running up
Go to All Programs > Microsoft SQL Server 2012 > Configuration Tools > SQL Server Configuration Manager > SQL Server Services
Check to make sure SQL Server service status is Running.
or
Open run command console(Windows + R) then type services.msc. You will all services in your system and check SqlServer (Sqlexpress) service is running mode.
Make sure your database engine is configured to accept remote connections
Start > All Programs > SQL Server 2005 > Configuration Tools > SQL Server Surface Area Configuration
Click on Surface Area Configuration for Services and Connections
Select the instance that is having a problem > Database Engine > Remote Connections
Enable local and remote connections
Restart instance using services.msc in run command window(discussed in #1)
Enable TCP/IP in SQL Server Configuration
Go to All Programs >> Microsoft SQL Server 2012 > Configuration Tools >> SQL Server Configuration Manager >> Select TCP/IP
Right Click on TCP/IP >> Click on Enable
Then restart the sqlserver service using services.msc in run command window(discussed in #1)
Lastly you need to check that it might be server firewall setting because sometimes firewall blocks incoming request from other servers. And also check you are providing correct connection string means username, password, server etc.
Thank You..
<connectionStrings>
<add name="conn2" connectionString="Data Source=192.?.?.?\your_db_instance;Initial Catalog=your_db_schema;Integrated Security=False;User ID=your_db_login;Password=??????" providerName="System.Data.SqlClient"/>
</connectionStrings>
As you are able to connect from SQL SMS, try to connect with the same remote parameters from Server Explorer window in Visual Studio as well. Click "add connection" on "Data Connections": Add Connection in Server Explorer. After the connection being created, get the connection string from the properties window by right clicking on the connection object. Use this connection string in the hosted web.config file.

Remote connection to SQL Server - Asp.net MVC

I'm currently setting up a remote SQL Server. Made all steps regarding remote connection (as found on http://blog.citrix24.com/configure-sql-express-to-accept-remote-connections/).
Let's say my servers are :
WEB
SQL
I can connect from WEB, using SQL Server Management Studio, to my SQL Server using my connection string. Using the same connection string in my web.config does not work, keep getting error 26 - Error locating server.
Connection string:
Data Source=169.254.196.1,1433;Initial Catalog=MyDb;User ID=myuser;Password=mypassword
Any ideas?

cannot establish a connection to SQL Server

I have a web app that I developed using Visual Web Developer 2010. The database is local inside the solution:
<add name="SFDBConnectionString"
connectionString="Data Source=.\SQLEXPRESS;AttachDbFilename=|DataDirectory|\SFDB.mdf;Integrated Security=True;User Instance=True"
providerName="System.Data.SqlClient" />
I'm trying to run the app on another machine using Visual Studio 2010 instead of the web developer and it's giving me the following error when it tries to connect to the database:
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)
Does anybody has any idea on what could be happening?
Usually, this error message means exactly what it says...
Can you connect to the SQL server through UI client (like, management studio)? If yes - how do you do that (user/password or Windows authentication; what is the server name)?
What is the connection string? You put here the connection string to SQL Express (which works; so it isn't quite helpful) - but forgot to put the connection string that doesn't work.
If you can connect in UI, and connection string is correct - there is no reason why the code would throw an error!

Visual Web Developer 2010 Express - limitations on accessing remote databases?

I'm using Visual Web Developer 2010 Express on my laptop to run some ASP.Net which is trying to access an Oracle database on another machine.
I've having some difficulties executing ...
SqlConnection myConnectionTest = new SqlConnection(s);
... and before I went any further I thought I should check .... does VWD2010 impose some sort of limitations on accessing remote databases ?
[Not sure if this is relevant the connectionStrings entry to oracle is using a TNS-less connection string like this :
<add name="ABC" connectionString="providerName="OraOLEDB.Oracle";Data Source=//foo.bar.com:1521/dev10.foo.bar.com;User Id=auserid;Password=apwd;"/>
There are no limitations that would prevent access to an Oracle Database
What is "missing" in the Visual Studio 2008 Express Editions?
This may be of some value:
Tips on Oracle Connection Strings
Mitch Wheat
Interesting point about the provider aspect of the connection string. If I don't put it into the string so that the connection string looks like this ...
<add name="ABC" providerName="OraOLEDB.Oracle" connectionString="Data Source=//foo.bar.com:1521/dev10.foo.bar.com;User Id=auserid;Password=apwd;"/>
... then I get an error which suggests that VWDC is trying to connect to a SQL Server database !
Ex.Message = 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: 25 - Connection string is not valid)
... the way that it seems to be defaulting to SQL Server which was what made me wonder initially whether there was some lim itation within VWDC.
Any comments on this welcome !
According to connectionstrings.com, a TSN-less connection string has the form:
Provider=OraOLEDB.Oracle;Data Source=(DESCRIPTION=(CID=GTU_APP)(ADDRESS_LIST=(ADDRESS=(PROTOCOL=TCP)(HOST=myHost)(PORT=myPort)))(CONNECT_DATA=(SID=MyOracleSID)(SERVER=DEDICATED)));User Id=myUsername;Password=myPassword;
Is 'providerName' also accepted?

unable to connect asp.net application with godaddy.com sql server database

I have domain on the godaddy.com. I have create the database over there.I am able to connect to the database from godaddy.com site with specified user name and password. but when i am going to use same information in my connection string in my asp.net web application on local machine it is showing
"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)"
This error.
my connectionstring is :
<add name="MyConnectionString"
connectionString="Data Source=myDataSource; Initial Catalog=MyDatabaseName; User ID=MyUserId; Password=MyPassword" providerName="System.Data.SqlClient" />
I have provided all required parameters to connection string here.I got this parameter information from godaddy.com database Description section.
You can't do that, their SQL server don't accept external connections.
[EDIT] OK, it seems that my first sentence is incorrect, look here:
http://community.godaddy.com/help/article/4978
http://community.godaddy.com/groups/web-hosting/forum/topic/ms-sql-remote-access/
http://help.godaddy.com/article/4977

Resources