473,544 Members | 1,972 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 2278
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
1502
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...
4
7958
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...
2
4293
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...
4
2644
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
7121
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...
3
1395
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...
2
1408
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...
2
2114
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....
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
2139
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. -------------------------------------------------------------------------------- ...
0
7602
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. ...
0
7764
jinu1996
by: jinu1996 | last post by:
In today's digital age, having a compelling online presence is paramount for businesses aiming to thrive in a competitive landscape. At the heart of this digital strategy lies an intricately woven tapestry of website design and digital marketing. It's not merely about having a website; it's about crafting an immersive digital experience that...
0
7704
tracyyun
by: tracyyun | last post by:
Dear forum friends, With the development of smart home technology, a variety of wireless communication protocols have appeared on the market, such as Zigbee, Z-Wave, Wi-Fi, Bluetooth, etc. Each protocol has its own unique characteristics and advantages, but as a user who is planning to build a smart home system, I am a bit confused by the...
0
5904
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...
1
5291
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...
0
4911
by: conductexam | last post by:
I have .net C# application in which I am extracting data from word file and save it in database particularly. To store word all data as it is I am converting the whole word file firstly in HTML and then checking html paragraph one by one. At the time of converting from word file to html my equations which are in the word document file was convert...
0
3407
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...
1
1837
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
1
983
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.