之前有建好数据库,在web.config中有:
 <connectionStrings>
  <add name="ConnectionString" connectionString="Data Source=machinename;Initial Catalog=mydb;Integrated Security=True" providerName="System.Data.SqlClient"/>
 </connectionStrings>但是asp.net configuration 连不上数据库:
Provider Management 
Could not establish a connection to the database. 
If you have not yet created the SQL Server database, exit the Web Site Administration tool, use the aspnet_regsql command-line utility to create and configure the database, and then return to this tool to set the provider. 请问Login控件是如何连接到数据库,是否和datalist控件一样需要绑定到数据库? 

解决方案 »

  1.   

    Login控件 里面的user 和 password信息是需要保存到数据库的一个表里面. 但是Login控件并没有特别指定数据库的某一个表.
    那么Login控件是如何连接数据库的呢?
      

  2.   

    有默认的数据库驱动,当你页面上拖个login控件后,浏览运行,在网站根目录的App_Data文件夹下面会有个aspnetdb数据库生成,这个数据库就是默认的login控件指定的数据库!
      

  3.   

    注意membership里面的数据库连接字符处要跟你现在用的一致!!
    <membership>
          <providers>
            <remove name="AspNetSqlMembershipProvider"/>
            <add name="AspNetSqlMembershipProvider" type="System.Web.Security.SqlMembershipProvider" connectionStringName="LocalSqlServer" enablePasswordRetrieval="false" enablePasswordReset="true" requiresQuestionAndAnswer="true" applicationName="/" requiresUniqueEmail="false" passwordFormat="Clear" maxInvalidPasswordAttempts="5" minRequiredPasswordLength="6" minRequiredNonalphanumericCharacters="0" passwordAttemptWindow="10" passwordStrengthRegularExpression=""/>
          </providers>
        </membership>
    connectionStringName="LocalSqlServer" 换成 connectionStringName="ConnectionString"
      

  4.   

    数据库是要用aspnet_regsql工具生成,然后在web.config文件中写入连接字符串。