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

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?

Related

VS2019 sql connection issue running asp.net project

I have sqlexpress installed on my dev laptop along with vs2019. I can access the sql instance in both SSMS and from the Server Explorer. When I go to debug and asp.net project, the sql connection fails with:
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)
This same configuration works on my desktop - same connection strings - no problem. And laptop sql is configured to allow remote connections.
Not sure what to do next?
Thanks
Abbott
Additional Info ...
I made sure the named pipes and tcpip were enabled and browser was working. Still had same error. Here are the connection strings. The desktop connection works on my desktop:
<!--Local DB For Desktop Testing-->
<!--<add name="DBConn" connectionString="data source=DESKTOP-QQOLG5N\SQLEXPRESS;initial catalog=kidsbookoutlet;integrated security=SSPI;persist security info=True;packet size=4096" />
<add name="KBODataEntities" connectionString="metadata=res://*/Context.KBODataEntities.csdl|res://*/Context.KBODataEntities.ssdl|res://*/Context.KBODataEntities.msl;provider=System.Data.SqlClient;provider connection string="data source=DESKTOP-QQOLG5N\SQLEXPRESS;initial catalog=kidsbookoutlet;integrated security=True;multipleactiveresultsets=True;application name=EntityFramework"" providerName="System.Data.EntityClient" />-->
<!--Local DB For Laptop Testing-->
<add name="DBConn" connectionString="data source=LAPTOPDELL\SQLEXPRESS;initial catalog=kidsbookoutlet;integrated security=SSPI;persist security info=True;packet size=4096"/>
<add name="KBODataEntities" connectionString="metadata=res://*/Context.KBODataEntities.csdl|res://*/Context.KBODataEntities.ssdl|res://*/Context.KBODataEntities.msl;provider=System.Data.SqlClient;provider connection string="data source=LAPTOPDELL\SQLEXPRESS;initial catalog=kidsbookoutlet;integrated security=True;multipleactiveresultsets=True;application name=EntityFramework"" providerName="System.Data.EntityClient"/>
Here's the ssms connection that works.
Do you have the sql server browser service running? Usually SSMS will complain, and since that is working, then this is a long shot. But I would ensure that not only is sql server service running, but also sql browser service.
This one:
Next up? Which provider in .net are you using to connect?
You have and can choose:
oleDB
ODBC
sqlProvider <- recommend this one
So, I would in the project settings, create a connection string here:
And for above, did you try the test connection button when you use the connection string builder:
This one:
I mean, why try running a bunch of code and all kinds of stuff. Now maybe you ARE talking about the conneciton builder in VS, and you can't connect.
However, if SSMS can, then VS should be able to.
So, does the test in above not work?
You can also try (and should) in the sql confi check the above screen cap if the browser service is running. And while you doing that, check the connections.
Expand the SQL Server Network Configuration
and look at these settings:
So before you write any code?
You check if browser service is running. Click/expand Protocols for sql express.
Then in VS you launch the connection builder and use the test connection.
All of the above is done in aobut 40 seconds tops of your time.
And these steps are quite much the first thing you will do.
Don't try and write code in VS just yet. Use the connection string builder.
You also failed to mention which provider you are using? (this is VERY troublsome, since you supposly dealing with conneciton problems, and you FAILED to mention what provider you are attempting to use.
As noted, you have 3 choices:
oleDB provider
ODBC provder
sqlProvider (this is the recommend .net provider - often called ado.net (but I NEVER know for what reason - that term should have been banished long ago for the poverty and confusing it caused over the years).
Anyway?
Spend 45 seconds checking the above, and then an additional 35 seconds creating a connection in VS. Just remember to choose the SAME provider in that connection builder as you using in code (1 of the above 3), and thus when you use test connection, you at least have a known working connection string, and a known working connection string for the given provider you are using here.

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?

ASP Login Control in IIS not working

I have developed a web site that utilizes login in control using the ASP.NET Web Site Administration Tool. I then moved the entire project over to the server that will be hosting the project. I have the site on IIS 7 but when I try to login, I get the error 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: 50 - Local Database Runtime error occurred. Cannot create an automatic instance. See the Windows Application event log for error details.
)
I have given the proper permissions to NETWORKSERVICE. It seems from browsing around online that this is a sql server problem. It works fine in VWD Express but not on IIS. I know that the roles,users,permissions are stored in a .mdf but I'm guessing that it's not being accessed correctly.
Does anyone have any insight on this?
Here is my connection string:
add name="DefaultConnection" connectionString="Data Source=(LocalDb)\v11.0;Initial Catalog=aspnet-GMPL-20130618083445;Integrated Security=SSPI;AttachDBFilename=|DataDirectory|\aspnet-GMPL-20130618083445.mdf"
providerName="System.Data.SqlClient"
Thank you in advance!
It's trying to use "LocalDB", which is probably not installed on your server. You probably should be connecting to a regular database, as opposed to LocalDB.
LocalDB is a new kind of SQL Express - seems to be made for development machines rather than for actual servers.
change Connection string to
"Data Source=.\SQLEXPRESS;Initial Catalog=DatabaseName;Integrated Security=True;MultipleActiveResultSets=True"

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!

Not able to connect to the SQL Server data from asp.net app

We are upgrading from an environment where the development web server, the SQL Server 2005, and SQL Server data are all on the same machine, a Windows XP Machine. We are upgrading to having the web server on one Windows 2008 server, the SQL Server on a 2nd Windows 2008 Server, and to Server to a Windows 2008 server, nd the data on a SAN.
Now we are getting the error message:
A connection was succesfully established with the server, but then
an error occured during the login
process. (provider: named pipes
provider, error 0, no process is on
the other end of the pipe.)
The network guy thinks it is a problem with the connection string:
<add name="CNString"
connectionString="Data Source=WEBSERVER;
Initial Catalog=PCIdb;
User ID=sa;Password=pass;"
providerName="System.Data.SqlClient"/>
Can anyone help out here?
Is your SQL Server really called WEBSERVER (DataSource="WEBSERVER") ??
Also, I would never EVER use the sa account in a connection string - NEVER, period. Use an application specific user or something, but do not use the sa account under any circumstances.
This can be caused by any number of reasons, but the first thing to look at is the configuration and setup of the SQL Server itself.
Are named pipes enabled on the server? You can check this through the server configuration manager (on the SQL Server machine itself).
Is the user on the connection string (or the connection pool user if you are using SSPI) setup on the server?
Note:
I do hope the connection string you put up is an edited version of your real one, as there are a couple of issues with it:
Using the sa login - you should never do that as now any SQL exploit can do any damage it wants
Calling a sql server "webserver" - a really confusion naming decision
When it comes to connection strings, look at connectionstrings.com - they hold a good list of valid connection strings to many databases using different providers.
I got that error before...Make sure SQL server services are started
If that's not it, change the authentication mode to both server and windows.
It could be a connectionstring problem. Try comparing your connectionstring to the connectionstrings at http://www.connectionstrings.com but it could also be that the remote connection or the remote server (the webserver in this case) isn't allowed to connect to SQL.
Check if remote connections are allowed and named pipes and/or TCP/IP protocols are enabled on the database server.
But, based on the scenario you've described, I'd say it's the database-end that's refusing the connection (since you've already had a working solution).

Resources