2

I have created a database MVCLearn with table general information

I want to display details in view with the help of Id, I used entity framework for data retrieving from database

so if i use id in url i will get the particular details of that person.

but when i run, browser is displaying an error this way

enter image description here

3
  • 1
    The error message is self-explanatory - the account you are connecting to the database with doesn't have permissions to do select queries on the db/table Commented Jun 7, 2016 at 15:17
  • Seems like an obvious error, the user context in the connection string you are using to connect to the database has no read/select permissions. So what is your question? Commented Jun 7, 2016 at 15:18
  • For retrieving data from database do we need to grant permissions for database so that we can use that data in project? If so how? Commented Jun 7, 2016 at 15:20

3 Answers 3

1

yes you need to grant at least read only permissions to your login which is used to access the database. Here you can find a good tutorial with pictures from Joel Lipman where all of these permissions are described: Create Read-Only Database User in SQL Server

I hope this helps.

Sign up to request clarification or add additional context in comments.

Comments

1

You need to create/modify a user on the SQL server that has the required permissions on that server. enter image description here

Use the User Mapping option. Then setup that user for EF

1 Comment

your Suggestion Worked
0

As the comments suggested, you need to grant permissions to your user to select data from the table. You can do this for a specific table like this:

grant select on dbo.tblEmployee to [YourUser]

However, it is more likely that you would want to add your user to a role, for selecting data only, you can use the following:

ALTER ROLE db_datareader ADD MEMBER [YourUser]

Hope this helps.

Comments

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.