Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations Mike Lewis on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

Gridview Hangs when user logged in

Status
Not open for further replies.

gbeckerleg

Programmer
Mar 19, 2008
4
GB
Hi,
I have set up a website that uses the microsoft security model. Users can log on to secure areas of the site and access secure pages with no problems.

I have now added a page that contains a gridview and if the user is in a particular role (Admin) they should get access to the EDIT and DELETE columns.

I can't seem to get this working correctly when I transfer the forms to my hosted website(im with eukhost).

If the user is not logged in they see the gridview fine, but if they are logged in the page appears to hang and eventually displays a page saying

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

the OnDataBinding event for the gridview contains code similar to this:
Code:
if(!user.isinrole("Admin"))
{
   gridview.column[0].visible = false;
}
(i dont have the exact syntax with me because i'm at work but I know it works because it's ok when I run from localhost but not from hosted site)

has anyone come across this before?
 
Apparently, it's a problem connecting to the SQL Server. Check the connection string and make sure it is correct for the web host.
 
what sort of thing could be wrong with the connection string? the same connection string is used to connect to the database whether the user is logged on or off? and it works when they are logged off?

The same connection string is used for the entire site and this is the only page that does not work, data retrieval and updating works everywhere except where I have added the if statement described above.
 
Good point. You will have to do some logging and check since you most likely won't be able to remotely debug. Also ask the host site if they can check their server's event log to get a more detailed description of the error.
 
thanks for the fast response, what do you mean by logging? Can you point me in the direction of a simple guide to asp.net logging and I'll have a go tonight and keep you updated.

cheers

Gerard
 
You can use an exceptioin manager to log to a file, the eventlog, a db or whatever. For now the errors should go to the server's event log. Ask the host company to check them for you.
 
Turns out the role provider was writing to a local database in the app_data folder which does not exist on the hosted site. Using this article I have now configured my role provider to use my sql database and this has solved the issue. Thanks for your help benson.
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top