473,804 Members | 3,067 Online
Bytes | Software Development & Data Engineering Community
+ Post

Home Posts Topics Members FAQ

Database Permission

Could someone please tell me how I can trap permission errors in
vb.net on a stored procedure:
ie. Execute permission denied on object 'sel_mytable', database
'mydatabase', owner 'dbo'

I would like to print a message like
response.write( "You don't have permission to select on this table") as
opposed to the cryptic message I am receiving.

Thanks in advance
Julie Barnet
Jul 20 '05 #1
3 2304
You can trap a SqlException and translate the error as desired in your code.
VB.Net WinForm example:

Try
sqlCommand.Exec uteReader()
Catch ex As SqlException
Dim PermissionError As Boolean = False
For Each sqlError As SqlError In ex.Errors
If sqlError.Number = 229 Then
PermissionError = True
Exit For
End If
Next sqlError
If PermissionError = True Then
MessageBox.Show ("You don't have permission to select on this
table")
Else
MessageBox.Show ("Unexpected error: " & ex.ToString())
End If
End Try

--
Hope this helps.

Dan Guzman
SQL Server MVP
"Julie Barnet" <ba*****@pr.fra serpapers.com> wrote in message
news:43******** *************** **@posting.goog le.com...
Could someone please tell me how I can trap permission errors in
vb.net on a stored procedure:
ie. Execute permission denied on object 'sel_mytable', database
'mydatabase', owner 'dbo'

I would like to print a message like
response.write( "You don't have permission to select on this table") as
opposed to the cryptic message I am receiving.

Thanks in advance
Julie Barnet

Jul 20 '05 #2
I am databinding a datagrid. I tried that and it still doesn't seem
to work. I will paste my code...

Is there something I'm missing?

Public Function BindGrid(ProcNa me as String, myDataGrid as
DataGrid, cmd as SqlCommand, con as SqlConnection) as Integer
Dim ds As DataSet
Dim da As new SqlDataAdapter( )

Try

cmd.CommandText = ProcName
cmd.CommandType = CommandType.Sto redProcedure
cmd.Connection = con

da.Selectcomman d = cmd

ds = new DataSet()
da.Fill(ds, "MyTable")

myDataGrid.Data Source=ds.Table s("MyTable").De faultView
myDataGrid.Data Bind()
return ds.Tables("MyTa ble").Rows.Coun t
catch exp as SqlException
HttpContext.Cur rent.Response.W rite("Exception 3")

End Try
End Function
Jul 20 '05 #3
I ran your code and got the "Exception3 " message. What symptoms are you
getting?

--
Hope this helps.

Dan Guzman
SQL Server MVP
"Julie Barnet" <ba*****@pr.fra serpapers.com> wrote in message
news:43******** *************** ***@posting.goo gle.com...
I am databinding a datagrid. I tried that and it still doesn't seem
to work. I will paste my code...

Is there something I'm missing?

Public Function BindGrid(ProcNa me as String, myDataGrid as
DataGrid, cmd as SqlCommand, con as SqlConnection) as Integer
Dim ds As DataSet
Dim da As new SqlDataAdapter( )

Try

cmd.CommandText = ProcName
cmd.CommandType = CommandType.Sto redProcedure
cmd.Connection = con

da.Selectcomman d = cmd

ds = new DataSet()
da.Fill(ds, "MyTable")

myDataGrid.Data Source=ds.Table s("MyTable").De faultView
myDataGrid.Data Bind()
return ds.Tables("MyTa ble").Rows.Coun t
catch exp as SqlException
HttpContext.Cur rent.Response.W rite("Exception 3")

End Try
End Function

Jul 20 '05 #4

This thread has been closed and replies have been disabled. Please start a new discussion.

Similar topics

3
1516
by: Mark | last post by:
Hi - I want to provide a secure (ASP) based file browser - based on a parent/child table of files/images etc - stored in a directory on a server. I want to be able to have individuals, who belong to groups, to be able to access various folders - no problem -assign a group to the folder, and check that that person belongs to one of the groups of the folder before displaying it. However, I want to go one further - rather than just 'can...
4
7975
by: TJ Olaes | last post by:
Hello all, this is my second post to this newsgroup. It's a question about stored procedures and permissions and how these behave between databases. Here's the scenario. I have a database that stores information for a system "A", and I have a different database on the same SQL server that stores the login and other info "LOGIN". I write a stored procedure in the "A" database that checks some tables in the "LOGIN" database, let's call...
2
4304
by: J.Beaulieu | last post by:
Hi I'll have probably to use sql server soon but prior to that I have a question concerning priviledges and security. Is it possible for someone to do like in access, ie creating a db/table that is locked with a password? My guess is that it will be yes but in cas of... Now is it possible for someone to make a db/table read only rather than to lock it totally? Also can the guy who has an administrator priviledge on the server determine...
4
2661
by: Nicolae Fieraru | last post by:
Hi All, I am working on a web site in asp which will be hosted on a Windows 2003 server. I use the following code to connect to the database: Set objConn = Server.CreateObject("ADODB.Connection") Set objRS1 = Server.CreateObject("ADODB.Recordset") objConn.Provider = "Microsoft.Jet.OLEDB.4.0"
14
7145
by: L Mehl | last post by:
I tested a FE/BE application developed in A2000 on a A2002 machine and got this message when exiting the app. Clicking the only available button "OK", exits the application, as intended. The FE is just the mdb, not an mde. FE and BE are in different directories on the same machine. Are there settings, preferably via code, that I can add to stop this error? Thank you for any help.
3
1411
by: MW de Jager | last post by:
I'm having endless problems with gaining access to an Access Database that sits on a different server. My ASP.NET app cannot gain control. The errror message I get is: The Microsoft Jet database engine cannot open the file '\\Server1\DataFolder\Countries5.mdb'. It is already opened exclusively by another user, or you need permission to view its data. I have setup the connection string to have the username = admin and the password is...
2
1418
by: Loane Sharp | last post by:
Hi there Please help! I'm at my wits' end... I am using the System.Data.SQLClient namespace in an ASP.NET web application to connect to a local instance of SQL Server 2005 Express. Using "AttachDBFileName" in the connection string to attach to the database, I can connect to the database if the ASPNET account is explicitly (a) granted database access and (b) given "SELECT" permission, presumably
2
2123
by: Enska | last post by:
I have problems connecting my access database I get information .. I cant use my database and I'm administrator on my computer so permission shutnot bee problem, but I dont know Where is the problem. Can enybody help me!!!! Server Error in '/Koulu/tietokannat' Application. -------------------------------------------------------------------------------- The Microsoft Jet database engine cannot open the file...
0
780
by: dphill | last post by:
Hello all I am a beginner .Net programmer so please forgive my ignorance. In brief, I am trying to read from xml file stored in a SQL database table’s field. This is what I used to create the table: CREATE TABLE Document ( DocID int IDENTITY NOT NULL, Description nvarchar(50) NOT NULL, DocumentStore xml NOT NULL,
2
2158
by: le0 | last post by:
guys, this is my first time to deploy website to the server, but every time i access the page this error always appears. --------------------------------------------------------------------------------------------- Server Error in '/sample' Application. -------------------------------------------------------------------------------- The Microsoft Jet database engine cannot open the file
0
9569
by: Hystou | last post by:
Most computers default to English, but sometimes we require a different language, especially when relocating. Forgot to request a specific language before your computer shipped? No problem! You can effortlessly switch the default language on Windows 10 without reinstalling. I'll walk you through it. First, let's disable language synchronization. With a Microsoft account, language settings sync across devices. To prevent any complications,...
0
10558
Oralloy
by: Oralloy | last post by:
Hello folks, I am unable to find appropriate documentation on the type promotion of bit-fields when using the generalised comparison operator "<=>". The problem is that using the GNU compilers, it seems that the internal comparison operator "<=>" tries to promote arguments from unsigned to signed. This is as boiled down as I can make it. Here is my compilation command: g++-12 -std=c++20 -Wnarrowing bit_field.cpp Here is the code in...
1
10302
by: Hystou | last post by:
Overview: Windows 11 and 10 have less user interface control over operating system update behaviour than previous versions of Windows. In Windows 11 and 10, there is no way to turn off the Windows Update option using the Control Panel or Settings app; it automatically checks for updates and installs any it finds, whether you like it or not. For most users, this new feature is actually very convenient. If you want to control the update process,...
0
9130
agi2029
by: agi2029 | last post by:
Let's talk about the concept of autonomous AI software engineers and no-code agents. These AIs are designed to manage the entire lifecycle of a software development project—planning, coding, testing, and deployment—without human intervention. Imagine an AI that can take a project description, break it down, write the code, debug it, and then launch it, all on its own.... Now, this would greatly impact the work of software developers. The idea...
1
7608
isladogs
by: isladogs | last post by:
The next Access Europe User Group meeting will be on Wednesday 1 May 2024 starting at 18:00 UK time (6PM UTC+1) and finishing by 19:30 (7.30PM). In this session, we are pleased to welcome a new presenter, Adolph Dupré who will be discussing some powerful techniques for using class modules. He will explain when you may want to use classes instead of User Defined Types (UDT). For example, to manage the data in unbound forms. Adolph will...
0
5503
by: TSSRALBI | last post by:
Hello I'm a network technician in training and I need your help. I am currently learning how to create and manage the different types of VPNs and I have a question about LAN-to-LAN VPNs. The last exercise I practiced was to create a LAN-to-LAN VPN between two Pfsense firewalls, by using IPSEC protocols. I succeeded, with both firewalls in the same network. But I'm wondering if it's possible to do the same thing, with 2 Pfsense firewalls...
0
5636
by: adsilva | last post by:
A Windows Forms form does not have the event Unload, like VB6. What one acts like?
1
4277
by: 6302768590 | last post by:
Hai team i want code for transfer the data from one system to another through IP address by using C# our system has to for every 5mins then we have to update the data what the data is updated we have to send another system
2
3802
muto222
by: muto222 | last post by:
How can i add a mobile payment intergratation into php mysql website.

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.