Jose
Jose

Reputation: 1140

Write access to a database using Visual Studio 2010

Please forgive me if I am somewhat vague on my question. I am following an online Tutorial which shows you how to create your own users, permissions, etc (within VS utilizing SQL). The problem I am having comes when Visual Studio tries to write to the database file. I have successfully created the database and connected to it utilizing Visual Studio, but when I run the code I receive the following error:

SqlException (0x80131904): Login failed for user Login failed for user 'DOMAIN\username'

now, I have checked and checked my credentials on SQL and I can succesfully create new dbs, modify, etc. I am truly lost at what the source of the problem might be, I have tried using different credentials to no avail! Is there a setting I must check within VS to give it admin rights to a database? I have tried so many different ways to solve this issue and have not found what I'm overlooking or doing wrong. Any help will be appreciated. Thank you!!!!!!!!

Upvotes: 0

Views: 951

Answers (1)

Gromer
Gromer

Reputation: 9931

There are two things going on here:

  1. The Membership users you want for your site, and
  2. Accessing your SQL Server database

You need to provide a connection string to your database, where the Membership provider will store user data. This username/password is not a user from your Membership datastore. Based on the error you posted, it looks like your connection string is using Integrated Security, so it would look something like:

Data Source=myServerAddress;Initial Catalog=myDataBase;Integrated Security=SSPI;

What you'll most likely want to do is setup a SQL Server Login to put in your connection string. Good reference: http://msdn.microsoft.com/en-us/library/aa337562(v=sql.105).aspx

Once the login is created, you can change your connection string to use the username & password you created the login with. Something like this:

Data Source=myServerAddress;Initial Catalog=myDataBase;User Id=myUsername; Password=myPassword;

Upvotes: 2

Related Questions