1

This is my connection string:

 <add name="modelConnectionString" connectionString="Data Source=.\SQLEXPRESS;AttachDbFilename='D:\Documents and Settings\Dima\My Documents\Visual Studio 2010\WebSites\WebSite10\App_Data\ASPNETDB.MDF';Integrated Security=True;User Instance=True;" providerName="System.Data.SqlClient"/>

It stopped throwing exceptions, but the access to the database doesnt seem to work, cause when i answer the confirmation question, it says it is wrong and wont let me in!!

    <membership defaultProvider="MyMembershipProvider">

  <providers>
    <clear/>
    <add
   name="MyMembershipProvider"    
   type="System.Web.Security.SqlMembershipProvider"      
   connectionStringName="modelConnectionString"             
   minRequiredPasswordLength="1"          
   minRequiredNonalphanumericCharacters="0"
   enablePasswordReset="true"
   maxInvalidPasswordAttempts="1000"
   passwordAttemptWindow="4000"
   enablePasswordRetrieval="true"
   requiresUniqueEmail="false"
   passwordFormat="Encrypted" 
   applicationName="/WebSite10"

   />
  </providers>
</membership>
3
  • First check the authentication mode of Sql Server you are connecting and then let me know all the details. Commented May 27, 2011 at 8:40
  • did you made an aspnet user in sqlserver ?and what privileges have you given Commented May 27, 2011 at 8:44
  • The authentication mode is "Forms".. Unfortunately, i dont know the procedure of making aspnet user and privileges. Commented May 27, 2011 at 9:02

2 Answers 2

2

You haven't specified a database name in the connection string - in the top one you are specifying the database file where you should be declaring the database name.

Server=.\SQLExpress;AttachDbFilename=c:\asd\qwe\mydbfile.mdf;Database=dbname; Trusted_Connection=Yes;

If you're attaching a database file to a local instance of SQL then you need to use the AttachDbFilename property.

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

13 Comments

Why do i need to use SQLExpress and not localserver.. the default server?.. well, i dont attach it. it is aspnetdb, which is created automatically by visual studio 2010
You don't need to use SQLExpress, that's just an example instance name. You need to specify where the server instance is for the database to be attached to.
i added your modification. now it doesnt throw an exception, it simply says the user name is not in the database. The instance is inside server explorer in visual studio. It was added by the program (VS2010) not by me
OK, the database connection is made then, now you've got enough to go on and work the rest out. That's nothing to do with the connection string, but to do with the membership provider. Look into using the WAT to manage the users for the membership provider.
Cannot open database "dbname" requested by the login. The login failed. Login failed for user 'DIMA-00AA1DA557\Dima'. -- Thats what i tried. it doesnt give me the old exception that i stated in the question. I still cant access the database. I wonder what you provide in the connection string or do in windows configuration to be able to enter the database
|
1

Can you not create the connection through the Visual studio server explorer. You can log into the server using the correct credentials then save the correct connection string to the config file.

There is a microsoft knowledge base article! on this.

1 Comment

Thanks for the link. But can u see why i fail to connect to the database with one of the connection strings from above?

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.