I have a local SQL Server database setup on a Dell R720 running Windows Server 2012 R2 and I am developing an ASP.NET site. I am able to connect to the database and pull in objects and queries and everything EXCEPT when I try to pull in the login tool.
I was following a tutorial on creating a login page and they suggested pulling in this tool, and clicking the login button which will prompt visual studio to create a new database with a bunch of tables in it, which they did successfully in the video but when I try it, I get this response:
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)
Here is my web.config file:
<?xml version="1.0" encoding="utf-8"?>
<configuration>
<connectionStrings>
<add name="SOSiQConnectionString"
connectionString="Data Source=KINGDOM_NETWORK;Initial Catalog=SOSiQ;Integrated Security=true;"
providerName="System.Data.SqlClient" />
<!-- commented this out testing the connection
<add name="SOSiQConnectionString1"
connectionString="Data Source=localhost\;Initial Catalog=SOSiQ;Integrated Security=True"
providerName="System.Data.SqlClient" /> -->
</connectionStrings>
Visual studio code showing SQL Server database connection
PS, I have searched google for days looking for a solution. Everybody suggests making sure that you have remote connections enabled and firewall/ports. I've done all that to no avail, but, in my mind it shouldn't matter because A. I am on the machine that has the SQL Server database and B. I can access the database from my project in Visual Studio.
Download SQL Server Express, even if you have a Standard or an Enterprise version already.
Related
I have created a web-service using asp.NET with SQL Server 2005 database. Then I published it to local IIS, but when I publish it Visual Studio showed me an error stated that:
the process cannot access the file (path to database) because it is being used by another process.
so, I Detach the database. then I published the web-service. Now, when Browsing my web-service from IIS Manager, and try to test some methods, an error page appears to say:
System.Data.SqlClient.SqlException: Invalid object name 'Student'.
where Student is a table in my database.
my connectionString is:
<add name="sbms" connectionString="Data Source=.\SQLEXPRESS;Integrated Security=True;User Instance=True" providerName="System.Data.SqlClient" />
Does Detaching the database cause this error? or there are errors in my ConnectionString? I search in Google and didn't find solution.
Please help me..
Detaching the database will cause the second error. The SqlClient can't find the table referenced by your code.
The first error comes from the database being opened in SQL Server in single user mode. Re-attach the database to SQL Server. Then change the connection settings to multiuser.
Detailed instructions for setting either single or multiple users
I am developing a web application using VS2012 and SQL server 2008 using windows authentication. When I am executing my application from my local VM it;s connecting to the database and working properly. But when I published the applictaion in a server IIS it is giving this error."no process is on the other end of the pipe". Both are using d same database server. here is my connection string.
<connectionStrings>
<add name="DbConnectionString" connectionString="Data Source=XXXXXX200;Initial Catalog=XXXXX_XXXXX;Integrated Security=SSPI;" providerName="System.Data.SqlClient"/>
</connectionStrings>
Even tried with
Integrated Security=true; and Trusted_Connection=yes;
And also by removing
providerName="System.Data.SqlClient".
But still it's giving error. But the same thing is working fine from development environment. But note from hosted server.
Can you please help me where and what I am missing.
refer this. this will give you instruction troubleshoot the issue
http://technet.microsoft.com/en-us/library/ms175496%28v=sql.105%29.aspx
I have made a MVC application that uses the built-in ASP.NET login functions. It works perfectly on my local machine. I have bought a webhosting service, because i want to publish my website to the internet.
How do i copy the membership and role database / tables to my new MS SQL Database and make it work with my current project?
In my Web.config i have:
<add name="ApplicationServices" connectionString="data source=.\SQLEXPRESS;Integrated Security=SSPI;AttachDBFilename=|DataDirectory|aspnetdb.mdf;User Instance=true" providerName="System.Data.SqlClient" />
notice that
Instance=true
This means that SQL Server Express will open the aspnetdb.mdf file, creating it on the fly first if needed.
When i try to login on my website i get the following error:
Sorry, an error occurred while processing your request.
Thanks
You need to run aspnet_regsql located in C:\Windows\Microsoft.NET\Framework\v4.0.30319. Just point it to your remote sql server and it should take care of the rest.
You will also need to edit your connection string for application services to the one for your remote sql server.
I created an ASP.NET website with Visual Studio 2008 sp1 and in the code I use SQL connection to reach a data base in my SQL Server 2008. It all wiorks great but then I wanted to deploy the website in IIS7 (Windows 7) which was hell to discover how to do it-
(I added a virtual directory and converted it to an application and only then it didn't show me the error that I was getting before I copied it to inetpub\wwwroot and converted it to an application). After doing it I tried to run it from the IIS7 but it just keeps showing me an error that it gets in the command sqlconnection.open() which works great when I run the website from the Visual Studio. How do I resolve this?
I am using the following connection string: "Data SourceEDI-PC\SQLEXPRESS;Initial Catalog=SyncMaster;Integrated Security=True"
And my IIS7 is on the same computer as the SQL Server, so what exextly do I have to do to make it work?
Your connection string probably looks like this...
<add name="ConnectionString"
connectionString="Data Source=servername;
Initial Catalog=dbname;
Integrated Security=True"
providerName="System.Data.SqlClient" />
Which means it is using the windows account IIS runs under, NETWORK SERVICE, to connect. When you run from Visual Studio it uses your windows account which has access to the SQL server.
Create a sql user to use as a service account and specify that info in the connection string. This way it will try to connect using the same account that you created in both Visual Studio and IIS.
ie.
<add name="ConnectionString"
connectionString="Data Source=servername;
Initial Catalog=dbname;
Persist Security Info=True;
User ID=sqluser;
Password=sqruserpassword"
providerName="System.Data.SqlClient" />
When running in IIS7 (or any other IIS for that matter) the connection to sql server is made as the user that runs the application pool in iis. In IIS7 this is usually NETWORK SERVICE. So if you are using integrated security, you need to grant this account access to the database. If your SQL server instance is running on another machine, say SQLSERVER01, and your web app is running on your machine, YOURMACHINE, then the NETWORK SERVICE account on your machine will be called YOURMACHINE$ as seen by SQLSERVER01.
I'm using an AspNetSqlMembershipProvider for my application.
On my development machine I recently deinstalled SQL Server 2005 Express and Management Studio Express so that I could install the full version of Management Studio. I chose not to install SQL Server 2005 because, well, I don't want to have unnecessary things running on my machine.
Now whenever my code attempts to do anything that relates to authentication I get an error of:
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)
So, what is the minimum amount of SQL Server I have to install in order for this to work?
You could get away without having any SQL Server instances installed, especially if all you're using it for is Membership, Roles and the default Profiles.
The default connection string often looks like this:
<connectionStrings>
<add name="LocalSqlServer"
connectionString="data source=.\SQLEXPRESS;Integrated Security=SSPI;AttachDBFilename=|DataDirectory|aspnetdb.mdf;User Instance=true"
providerName="System.Data.SqlClient"/>
</connectionStrings>
If you change your SQL connection string, to match the value of "connectionString" above, that will force ASP.NET to generate the standard ASP.NET database for you withing the "App_Data" folder of your site - the keep part is "AttachDBFilename" which tells it to open the mdf file directly rather than attach to a SQL instance.
However, you might have some difficulty connecting to that file with SQL Management Studio.
You'll probably have to change the connection string once you move the site off development and into production, to point to a full instance of SQL if you so wish, rather than stick with the file based version.
Alternatively, what I tend do is have SQL Server installed (Express or otherwise), but the services stopped unless I'm actually using them. Then I just start them up when I'm developing.
Also you can have the Express version of SQL Server installed on the same machine as theh the full version SQL Management Studio without any problems.