SQL Permission Errors
am 09.11.2004 15:06:24 von Drew
Is it possible to show a generic error page when a user doesn't have access
to the SQL Server? As it is now, if a user doesn't have permission to a DB
on the SQL Server, and navigates to a page or app that uses that DB, it
gives them a "Page cannot be found" error, with more abotu the error below.
I would like to show a friendly "You do not have permission to access this"
instead.
Thanks,
Drew
RE: SQL Permission Errors
am 17.11.2004 21:00:02 von JohnBeschler
There may be other, better ways to do this, but here's one suggestion.
Enclose your code that opens the connection inside an on error resume next
block and check the connection state yourself in the code. If the connection
is not open, then redirect the user to a page that displays your error
message (Or display it in line in the page).
Don't forget to reset your error handling after you are done.
Here's some pseudo code to give you an idea.
On Error Resume Next
Set oConn = Server.CreateObject("ADODB.Connection")
szConnStr = "PROVIDER..." ' Connection string goes here.
oConn.Open szConnStr
If oConn.State = 1 THEN ' Connection open
'Process your code for the database
Else ' Connection NOT open
'Process your error message(s)
End If
On Error .... 'To reset your error handling.
Hope that will at least point you in the right direction.
"Drew" wrote:
> Is it possible to show a generic error page when a user doesn't have access
> to the SQL Server? As it is now, if a user doesn't have permission to a DB
> on the SQL Server, and navigates to a page or app that uses that DB, it
> gives them a "Page cannot be found" error, with more abotu the error below.
> I would like to show a friendly "You do not have permission to access this"
> instead.
>
> Thanks,
> Drew
>
>
>