Click here to Skip to main content
15,890,557 members
Please Sign up or sign in to vote.
0.00/5 (No votes)
See more:
My problem is related to c# and SQL server express 2008. i am performing functions on the live server.. my application is working fine with the live server, i am able to fetch and display data from the server into my website.. the only problem which i am having is while login with login control. i am getting the following error while login..

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)

XML
Source Error:


Line 26:         if (string.IsNullOrEmpty(Request.QueryString["ReturnUrl"]))
Line 27:         {
Line 28:             if (Roles.IsUserInRole(Login1.UserName, "admin"))
Line 29:                 Response.Redirect("~/admin/add-product.aspx");
Line 30:             else

i have written code on logged_in event of login control like below


        if (string.IsNullOrEmpty(Request.QueryString["ReturnUrl"]))
        {
            if (Roles.IsUserInRole(Login1.UserName, "admin"))
                Response.Redirect("~/admin/add-product.aspx");
            else
                Response.Redirect("~/ProfileInfo.aspx");
        }


i am not able to understand what's the problem.. because i am free to perform any other function..

One more thing when i connect from local host with the live server then it works fine...


My web config file is like below..


XML
<location path="admin">
  <system.web>
    <authorization>
      <allow roles="admin" />

      <deny users="*"/>
    </authorization>
  </system.web>
</location>
<system.web>
Posted
Updated 7-Oct-13 0:52am
v4

Probably in your local development server SQLExpress is present and your application is using that db using attachdb method but in your production server may be SQLExpress is not present.

Hope this will help you.
 
Share this answer
 
Comments
Harpreet_125 7-Oct-13 7:19am    
but i am able to connect and fetch other data from the server.. i am only getting error while login..
M Rayhan 7-Oct-13 7:24am    
You fetch data from other database but can you please check whether you can fetch data from any tables of Asp.Net membership DB??
Harpreet_125 7-Oct-13 7:34am    
how can i solve this problem??
Check your membership provider connection string in web.config
 
Share this answer
 
Comments
Harpreet_125 7-Oct-13 6:54am    
it is also same like other.. and it is correct.. because it works fine on localhost with the live server..

This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)



CodeProject, 20 Bay Street, 11th Floor Toronto, Ontario, Canada M5J 2N8 +1 (416) 849-8900