Showing posts with label object. Show all posts
Showing posts with label object. Show all posts

Friday, February 17, 2012

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 BarnetYou can trap a SqlException and translate the error as desired in your code.
VB.Net WinForm example:

Try
sqlCommand.ExecuteReader()
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" <barnetj@.pr.fraserpapers.com> wrote in message
news:438e1811.0312081052.d233a1f@.posting.google.co m...
> 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|||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(ProcName 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.StoredProcedure
cmd.Connection = con

da.Selectcommand = cmd

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

myDataGrid.DataSource=ds.Tables("MyTable").DefaultView
myDataGrid.DataBind()
return ds.Tables("MyTable").Rows.Count

catch exp as SqlException
HttpContext.Current.Response.Write("Exception3")

End Try
End Function|||I ran your code and got the "Exception3" message. What symptoms are you
getting?

--
Hope this helps.

Dan Guzman
SQL Server MVP

"Julie Barnet" <barnetj@.pr.fraserpapers.com> wrote in message
news:438e1811.0312090444.3e7dd4ab@.posting.google.c om...
> 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(ProcName 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.StoredProcedure
> cmd.Connection = con
> da.Selectcommand = cmd
> ds = new DataSet()
> da.Fill(ds, "MyTable")
> myDataGrid.DataSource=ds.Tables("MyTable").DefaultView
> myDataGrid.DataBind()
> return ds.Tables("MyTable").Rows.Count
>
> catch exp as SqlException
> HttpContext.Current.Response.Write("Exception3")
> End Try
> End Function

database performance management

Hi
I am using SQL server database with asp as front end. I use asp command object to call sql stored procedure. The procedure runs a while loop for say 100,000 records and based on the IF condition calls particular stored procs which process the record.
I am running this app on a p4 IBM pc with win 2000 sever and IIS on same m/c . The cpu utilisation goes upto 98-99% and the process has started running very slow of late. Is this slow processing speed a hardware/OS problem or is it due to calls for stored proc within stored proc? how can i optimise the process. Each stored proc called does have if conditions,table scans etc.

please adviseYou might post your SP for more help, might try recompiling it as well.|||I have attatched the main stored proc(fetchobktotmp_SP_March08.txt) and the proc which is called most often(sot_Sp_March08.txt.. please have a look
regds|||Both SQL & ISS on same machine will have resource crunch and performance would be affected, try to seperate them or add more physical memory to the box. And also assign more memory to SQL itself.

As suggested recompile the SP, update stats the involved tables etc etc.|||Having SQL Server as well as IIS on the same machine leads to a perrformance crunch but inorder to really identify what is the issue you would need to check, RAM & Processor speed. They play a big part.

It is important to identify if this is processor issue or RAM issue, and you would need to check through performance monitor what are the CPU cycle consumption patterns of the IIS and SQL Server.

At the SQL Server level itself, you can check using the trace files if there are any other issues. But i guess, these kind of performance testing has to be done over a period of time and then analyse the results.|||Contribution- http://www.sql-server-performance.com/q&a45.asp|||Hi
currently the machine has 512MB RAM.. we hve observed that as no of records in the table increases (say 600000 or so) thge performance degrades.. for starters we hve decided to hve a serer grade machine for SQL server and iis both.. may be we wud even seperate them ..|||I feel the server is stressed out due to both at one place and SQL is not able to exeucte queries due to less available resources, such as memory which will have major affect for any performance.