ADO/ADO.NET - problem in SqlServer for retriving the data  ADO/ADO.NET - problem in SqlServer for retriving the data

Asked By Sweacha laxmi
11-May-11 03:22 AM
Hello to all,
      I have a project And iam running in visualstudio.This project is a developed with Asp.Net with C# code and my problem is when ever iam running the code my pages opening in browser but when iam signing or creating a new user Iam getting error as follows:


An error has occurred while establishing a connection to the server.  When connecting to SQL Server 2005, this failure may be caused by the fact that under the default settings SQL Server does not allow remote connections. (provider: SQL Network Interfaces, error: 26 - Error Locating Server/Instance Specified)


Why this error is raising?


Thanx in Advance,
  dipa ahuja replied to Sweacha laxmi
11-May-11 03:32 AM
Check your Connection String:

connectionString="Data Source=.\SQLEXPRESS;AttachDbFilename=|DataDirectory|\ASPNETDB.MDF;Integrated Security=True;User Instance=True"

write the .\SQLEXPRESS in the dataSource
  Bala Marish replied to Sweacha laxmi
11-May-11 04:01 AM
add \ to nearerby the .\sqlexpress
  TSN ... replied to Sweacha laxmi
11-May-11 04:26 AM
hi..

 Networking protocols are disabled by default in SQL Server Express.

If someone simply installs Express and chooses all the defaults, SQL Server Express will only
be able to have connections originating on the local machine where SQL Server is installed.

You need to expressly enable networking protocols on the production server.

Follow the instructions outlined at :

http://blogs.msdn.com/sqlexpress/archive/2005/05/05/415084.aspx
and
http://forums.microsoft.com/MSDN/ShowPost.aspx?PostID=271795&SiteID=1

hope this helps you...
  James H replied to Sweacha laxmi
11-May-11 04:32 AM

ADO.Net makes connections to SQL databases very easy. Visual Studio ships with SQL Express for development, but can only be used on the local machine. SQL Server and SQL Express are essentially the same.

In this short example we create the objects necessary to connect to a SQL database, query a table, retrieve the results and display them. You may have to change the database path depending on the location, and contents, of your SQL Express sample databases. Sample databases for SQL Express can be downloaded from the http://www.microsoft.com/downloads/details.aspx?familyid=06616212-0356-46a0-8da2-eebc53a68034&displaylang=en.

We have used the "@" symbol to denote a verbatim string, a string that is taken as is. This allows for multi line strings and we do not have to escape characters such as backslash in filenames. It also means that the connection string is more readable when separated onto multiple lines.




string connectionString = @"Data Source=.\SQLEXPRESS;AttachDbFilename=""C:\SQL Server 2000 Sample Databases\NORTHWND.MDF"";Integrated Security=True;Connect Timeout=30;User Instance=True";
  
SqlConnection sqlCon = new SqlConnection(connectionString);
sqlCon.Open();
  
string commandString = "SELECT * FROM Customers";
SqlCommand sqlCmd = new SqlCommand(commandString, sqlCon);
SqlDataReader dataReader = sqlCmd.ExecuteReader();
  
while (dataReader.Read())
{
  Console.WriteLine(String.Format("{0} {1}", dataReader["CompanyName"], dataReader["ContactName"]));
}
dataReader.Close();
sqlCon.Close();

Hope this will help you :-)
  Anoop S replied to Sweacha laxmi
11-May-11 04:32 AM
This problem may occur when SQL Server 2005 is not configured to accept remote connections. By default, SQL Server 2005 Express Edition and SQL Server 2005 Developer Edition do not allow remote connections. To configure SQL Server 2005 to allow remote connections, complete all the following steps:
  • Enable remote connections on the instance of SQL Server that you want to connect to from a remote computer.
  • Turn on the SQL Server Browser service.
  • Configure the firewall to allow network traffic that is related to SQL Server and to the SQL Server Browser service.

Have a look at the following KB article, it will take you through the process of allowing remote connections.

How to configure SQL Server 2005 to allow remote conections
http://support.microsoft.com/default.aspx?scid=kb;EN-US;914277

  Riley K replied to Sweacha laxmi
11-May-11 04:32 AM

I eventually found the resolution to this error so I was saved from hunting for the solution. I am sure there are a number of developers who had previously fixed this error while installing SQL Server 2008 or SQL Server 2005 but in due course forgot the right solution to this error. 


Let us check into the steps to resolve this error.

1) SQL Server should be up and running.

Go to All Programs >> Microsoft SQL Server 2008 >> Configuration Tools >> SQL Server Configuration Manager >> SQL Server Services, and check if SQL Server service status is “Running”.

In addition, ensure that your remote server is in the same network. Run “sqlcmd -L” in your command prompt to ascertain if your server is included in your network list.

I have confronted numerous situations when these nerve-wracking errors crop up, and most of the time when I try to troubleshoot I notice that SQL Server services are neither running nor installed. If SQL Server is not installed as default instance SQL Server Browser should be running together with it; we will explore this further in Topic 5.

2) Enable TCP/IP in SQL Server Configuration

When two or more SQL Servers are connected across network they do all communication using TCP/IP. The default port of SQL Server installation is 1433. This port can be changed through SQL Server Configuration Manager. TCP/IP should be enabled for SQL Server to be connected.

Go to All Programs >> Microsoft SQL Server 2008 >> Configuration Tools >> SQL Server Configuration Manager >> Select TCP/IP

Right Click on TCP/IP >> Click on Enable

You must restart SQL Server Services for all the changes to take effect. Right click and go to menu properties to select location where default port of SQL Server can be changed.

3) Open Port in Windows Firewall

Windows Firewall is very efficacious in protecting the Operating system from all sorts of malicious attacks. By default, many of the ports and services are refrained from running by firewall. Time and again, SQL Server ports are not open in firewall as well. All the ports on which SQL Server is running should be added to exception and firewall should filter all the traffic from those ports. As described, by default SQL Server runs on port 1433, but if default port is changed then the new port should be added to exception. If SQL Server has named instance (another instance besides default instance) is installed, SQL Server browser should also be added to the exception, as described in Step 7.

Go to Control Panel >> Windows Firewall >> Change Settings >> Exceptions  >> Add Port

Make the following entries in popup “Add a Port” and click OK.
Name : SQL
Port Number: 1433
Protocol: Select TCP

4) Enable Remote Connection

Enabling remote connection is another important, yet oft-neglected step that is frequently missed by database administrators while setting up SQL Server. If this feature is turned off SQL Server will function smoothly on local machine, but it will let another server connect to it remotely. By default this feature is ON in SQL Server 2008.

Right click on the server node and select Properties.

Go to Left Tab of Connections and check “Allow remote connections to this server”

5) Enable SQL Server Browser Service

If SQL Server is not installed as default instance but instead installed as named instance and also if there is no specific TCP/IP port configured, it will give rise to the error that is being discussed in this article. If SQL Server Browser service is enabled, it will allow the server to be connected through dynamic TCP/IP port. Enabling this service is a one-time process, as on enabling it once it will apply to all the instances installed on the same server.

Go to All Programs >> Microsoft SQL Server 2008 >> Configuration Tools >> SQL Server Configuration Manager >> SQL Server Browser

Right Click on SQL Server Browser >> Click on Enable

6) Create exception of sqlbrowser.exe in Firewall

As elucidated in Step 6, sqlbrowser service needs to be enabled for named instance. Windows Firewall may prevent sqlbrowser.exe to execute. So, it is imperative to add exception for the same in windows firewall.

Search for sqlbrowser.exe on your local drive where SQL Server is installed. Copy the path of the sqlbrowser.exe like C:\Program Files\Microsoft SQL Server\90\Shared\sqlbrowser.exe and create the exception of the file in Firewall, as delineated in Step 3.

7) Recreate Alias

It is getting quite common to create alias of SQL Server and use it in application. This will ensure that in future if any physical SQL Server has to be moved, it will not be required to change any code or connection string. You can simply create alias with the same name pointing to different SQL Server and it will start working instantaneously. I have observed that a couple of times due to internal error while recreating alias this error was fixed.

Go to All Programs >> Microsoft SQL Server 2008 >> Configuration Tools >> SQL Native Client 10.0 Configuration >> Aliases

Delete the alias that is giving problem and recreate it with identical parameters.

  Reena Jain replied to Sweacha laxmi
11-May-11 04:33 AM
hi,

try the following steps

Step 1) Make sure SQL SERVER is up and the instance you try to connect is running.
Step 2) Your system Firewall should not block SQL Server port.
Step 3) Go to Computer Management >> Service and Application >> SQL Server 2005 Configuration >> Network Configuration
Enable TCP/IP protocol. Make sure that SQL SERVER port is by Default 1433.
Step 4) Now follow this KB Article of MSDN depending on your server

Hope this will help you
  Ravi S replied to Sweacha laxmi
11-May-11 04:34 AM
HI

The reason that we get this error message is the client stack could not receive SSRP response UDP packet from SQL Browser. It's easy to isolate the issue.

Here are the steps:

1) Make sure your server name is correct, e.g., no typo on the name.

2) Make sure your instance name is correct and there is actually such an instance on your target machine. [Update: Some application converts \\ to \. If you are not sure about your application, please try both Server\Instance and Server\\Instance in your connection string]

3) Make sure the server machine is reachable, e.g, DNS can be resolve correctly, you are able to ping the server (not always true).

4) Make sure SQL Browser service is running on the server.

5) If firewall is enabled on the server, you need to put sqlbrowser.exe and/or UDP port 1434 into exception.

Sample

Data Source=myServerAddress;Initial Catalog=myDataBase;User Id=myUsername;Password=myPassword;

refer the link
http://blogs.msdn.com/b/sql_protocols/archive/2007/05/13/sql-network-interfaces-error-26-error-locating-server-instance-specified.aspx
Create New Account
help
to embedd it, anyone has experience with this? any reason why you aren't using sql server compact edition? http: / / www.microsoft.com / sqlserver / en / us / editions / compact.aspx just out of interest. . . that seems interesting Only problem i have no idea how to use it, i download sql compact 4.0, do i have to use sql server 2008 managment, clueless Microsoft SQL Server Compact 4.0 is the next generation of embedded database
Frequently asked Interview Questions in ADO.Net hi friends Any one send frequently asked Important questions in C# .Net, ADO .Net, Asp .Net and Sql Server. . . . . . . . tx in Advance. . . . . . Hi, Find this. . (B)What is an IL? (B)What is a objects in Remoting? (A) What are the ways in which client can create object on server in CAO model? (A) Are CAO stateful in nature? (A) To create objects in CAO What are the steps to configure StateServer Mode? (A) What are the steps to configure SQLServer mode? (A) Where do you specify session state mode in ASP.NET? (B) What are
Setup MS Office SharePoint 2007 Test / Dev Environment Authentication Problems Hello all, i like to setup a fast clonable test / development installation of MOSS2007 under Windows 2008 SP1 (not R2) (32bit). As starting point I have choosen the Blog post from here This means the installation should be on a single server as Domain Controller , as MS SQL database server and as MOSS2007 server farm. Only one uses should be used. Thats what I have done, I followed the I am reading the logfiles placed under "c: \ program files \ common files \ microsoft shared \ web server extensions \ 12 \ logs". I don't find any relavant information regarding authentication or what else Anmeldung.' Source: '.Net SqlClient Data Provider' Number: 4060 State: 1 Class: 11 Procedure: '' LineNumber: 65536 Server: 'd-it5-sptest-dc' 03 / 04 / 2010 13:53:11.35 OWSTIMER.EXE (0x0980) 0x0988
a single.NET DLL contain? Answer1: As many Answer2: One or more What are good ADO.NET object(s) to replace the ADO Recordset object? The differences includes In ADO, the in-memory representation of data is the recordset. In ADO.net, it is the dataset A recordset looks like a single table in ADO In contrast, a dataset is a collection of one or more tables in ADO.net ADO is designed primarily for connected access ADO.net the disconnected access to the