SQL Server Error

Hello Every Body

How r u

i face a problem so please any body help me

i create two data base in sql server 2012 and connent with ASP.net (VB.Net) both data base connections establish but one data base work perfectly but the other data base doest not wort when run query 

sql = "Select * from [Table]"
        con = New Conn_LM()
        Dim cmd As New SqlClient.SqlCommand(sql, con.returnCon)
        Dim DA As SqlClient.SqlDataAdapter = New SqlClient.SqlDataAdapter()
        DA.SelectCommand = cmd
        Dim DS As DataSet = New DataSet()
        DA.Fill(DS)

when run this error is this

Error "5" The Select permission was denied on the object

any body help me 

thanks in advance

July 22nd, 2015 12:47pm

Hello Rick Byham Please tell me in detail how to execute 

SELECT USER; to see verify the name of the user you connected as.

My error occur on this line i tell in detail

I create two data base in sql server 2012 and connect with ASP.net (VB.Net) both data base connections establish and one data base perform work (Select Insert ... and other commands) perfectly but the other data base does not work (Select Insert ...) when run query 

sql = "Select * from [Table]"
        con = New Connection()
        Dim cmd As New SqlClient.SqlCommand(sql, con.returnCon)
        Dim DA As SqlClient.SqlDataAdapter = New SqlClient.SqlDataAdapter()
        DA.SelectCommand = cmd
        Dim DS As DataSet = New DataSet()
        DA.Fill(DS)

when the cursor comes at last line (DA.Fill) then the error occur

1. Please tell how to check user permissions while the second database is also run perfectly and no error occur  

both r connect with the same user

i run this query

SELECT logins.name, roles.name
	FROM sys.server_principals logins 
		INNER JOIN sys.server_role_members rm ON logins.principal_id = rm.member_principal_id
		INNER JOIN sys.server_principals roles ON rm.role_principal_id = roles.principal_id
	WHERE logins.name = SUSER_SNAME()

 and see the result my name is sysadmin 

but the result same 

Free Windows Admin Tool Kit Click here and download it now
August 1st, 2015 6:36am

You have hidden what comes after FROM. That is a pity. Is that a table in the current database, or is it in a different database? Is it a view?

If you want help, you need to help us to help you. If you withhold information from us, we can only guess, and maybe not even that, and you will not get the issue resolved here.

August 2nd, 2015 5:34am

Yes this is a table of current database
Free Windows Admin Tool Kit Click here and download it now
August 2nd, 2015 7:15am

You said SELECT USER returned dbo. Since dbo has access to all tables in the database, there is something that is not correct.

As I said, if you don't help us to help you, we can't help you.

August 2nd, 2015 7:36am

Yes this is a table of current database

It looks like the Windows account used from the ASP.NET web application is different than the one used to run the SELECT USER query.  Try running the SELECT USER query from your ASP.NET code running on the server.

 
Free Windows Admin Tool Kit Click here and download it now
August 2nd, 2015 7:59am

Abdullah,

I think you are specifying Integrated Security in your connection string since you're using Windows Authentication.

You will be authenticating as whatever domain account ASP.NET is running under, which is probably the network service account.

Your application is likely connecting as a totally different user than your account, and this other login doesn't have the permissions for this operation. Hence the "The SELECT permission was denied".

In ASP.NET, in similar cases, you have to add DOMAIN\MACHINENAME$ to your SQL Server and give it the right permissions.

Hope this helps!

August 2nd, 2015 8:18am

This topic is archived. No further replies will be accepted.

Other recent topics Other recent topics