Hi Folks,

I have created a login page that allows user to login to the system. I have a table in database called Users (userid, password, roleid) . When I try to login with proper user id and password the system let me login and redirects to proper page but if I use wrong password rather than giving me an error message the system generates an exception

"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)"

I know that there is no connection error as when I use proper login credentials it let me in to the system. What is the potential cause of this behaviour ? I am using SQL Server 2008.

>What is the potential cause of this behaviour ? I am using SQL Server 2008.

MS-SQL server is not installed properly OR MS-SQL server instance is not started yet. I think you have MS-SQL 2008 Express edition.

>What is the potential cause of this behaviour ? I am using SQL Server 2008.

MS-SQL server is not installed properly OR MS-SQL server instance is not started yet. I think you have MS-SQL 2008 Express edition.

I am using MSSQL Server 2008 Standard Edition full version and not the Express Edition. If it is not installed properly then how can it allows user to login when credentials are correct. I only have this exception occurring when user fill wrong user id and password in login.aspx

Woohoo ... I solved the problem today....

The issue was rather strange. What was happening is I was using user name and password stored in my database table to login to the system. I also set up Forms based authentication to restrict users to access certain part of the website. The issue was not with the programming but with the behavior of ASP.NET and it was trying to find instance of SQLEXPRESS which is not there using LocalSqlServer connection string defined in IIS. So I removed LocalSqlServer in web.config and create a custom membership provider class that will use my own login logic to login to the system and set login control in my website to use that membership provider.

<remove name="LocalSqlServer" />
<membership defaultProvider="MyCustomMemershipProvider">
      <providers>
        <clear/>
        <add
          name="MyCustomMemershipProvider"
          type="BBCApplication.BusinessLogic.MyCustomMemershipProvider"/>
      </providers>
    </membership>

Hi Folks,
Hai,
Solution to you problem is that create a to layer under the app_code in the asp.net and inside it create foder business logic layer and data access layer and make a class inside these two layer for your login logic . Use AdO.net object data set with a dataset method in the code and create cookies of the userid inside the login button

Be a part of the DaniWeb community

We're a friendly, industry-focused community of developers, IT pros, digital marketers, and technology enthusiasts meeting, networking, learning, and sharing knowledge.