Link to home
Create AccountLog in
Avatar of dshrenik
dshrenikFlag for United States of America

asked on

Change Database permission to Read/Write using Visual Studio 2010

Please let me know how one can change a database's permissions to read/write using queries, in Visual Studio 2010.

If possible, please give me the step by step procedure.
Thanks!
Avatar of flytox06
flytox06
Flag of France image

Hi,

You should have the corresponding rights and launch following query :

ALTER DATABASE mydatabase READ_WRITE


Good luck !
Avatar of dshrenik

ASKER

Please let me know where (in Visual Studio 2010) I can execute this query.
SOLUTION
Avatar of flytox06
flytox06
Flag of France image

Link to home
membership
Create an account to see this answer
Signing up is free. No credit card required.
Create Account
Can't I execute the query using Visual Studio 2010? I remember someone saying in a forum that it can be done. Maybe he's wrong. Please let me know.
Also, does it come bundled with Visual Studio 2010 installation?
SOLUTION
Link to home
membership
Create an account to see this answer
Signing up is free. No credit card required.
Create Account
Yeah.. I figured that out. But, I'm not sure how to proceed from there. Where exactly do I enter the query and how do I run it?
you type the query I gave you, you click on Execute.

but if you wonder those kind of thing, I guess you don't have the rights to do it.
I'm sure I have the permissions.

I right click on the database name under, Data Connections, and then say 'New Query', and it then shows me a list of tables. Here's where I'm not sure what to do.
Even if I select some random tables, and enter the query, I don't see any 'Execute' button or option.
SOLUTION
Link to home
membership
Create an account to see this answer
Signing up is free. No credit card required.
Create Account
Thanks for the link.

When I try to execute "ALTER DATABASE ASPNETDB.MDF READ_WRITE", it says "Msg 102, Level 15, State 1, Line 1
Incorrect syntax near '.'."

"ALTER DATABASE ASPNETDB READ_WRITE" does not woek as well.
1) is ASPNETDB your database to alter ?
2) what is error for 2nd statement ?
Yes. That is the default database created by Visual Studio for an website.

I get the following error for the second statement:
"Msg 102, Level 15, State 1, Line 1
Incorrect syntax near 'READ_WRITE'."
SOLUTION
Link to home
membership
Create an account to see this answer
Signing up is free. No credit card required.
Create Account
When I execute "ALTER DATABASE ASPNETDB SET READ_WRITE", I get the following error:

The database has been created by me and I am the administrator on my laptop. So what could the problem be?
Msg 5011, Level 14, State 5, Line 1
User does not have permission to alter database 'ASPNETDB', or the database does not exist.
Msg 5069, Level 16, State 1, Line 1
ALTER DATABASE statement failed.

Open in new window

ASKER CERTIFIED SOLUTION
Link to home
membership
Create an account to see this answer
Signing up is free. No credit card required.
Create Account
Sorry to ask too many questions, but can you tell me how I can do that?
SOLUTION
Link to home
membership
Create an account to see this answer
Signing up is free. No credit card required.
Create Account
I guess I do not have an SQL Server account. Could you tell me how I can create one?
Apologies again, for asking too much!
you said you created the database, you have been asked to input an administrator password.

use login = "sa" and password = "yourpassword"

to go ahead, I advise you log on the server itself and user SQL Server Management Studio, you'll get a better view of the server.
Well, I did not create the database myself. It was created automatically by Visual Studio 2010 when my website was launched.

I do not have  SQL Server Management Studio installed. Does it come bundled with Visual Studio 2010?
SOLUTION
Link to home
membership
Create an account to see this answer
Signing up is free. No credit card required.
Create Account
aspnetdb.mdf is not readonly.

I have attached a screenshot of the results.
DB.png
I'm not clear with 1 thing - say I have several .MDF files on my computer, how do I select a particular instance to apply queries on?
SOLUTION
Link to home
membership
Create an account to see this answer
Signing up is free. No credit card required.
Create Account
Thank you! :)
Another useful link - Walkthorugh to create and execute Transact-SQL script:
http://msdn.microsoft.com/en-us/library/aa833241.aspx