我的机器有问题,我不得不重建它。我重新安装了所有软件并将我的项目备份重新放回到机器上。我一直在努力解决我无法解决的SQL连接问题。
因此,在经历了许多更改和错误之后,我将工作生产版本放回我的机器上。当我运行它时,我收到以下错误: 分析程序错误消息:未知数据库'p10009307_sec'
我的SQL Workbench知道数据库,如果我在页面上删除数据库连接并配置它我可以连接。
问题是它在哪里找不到MySQL?我假设它在Webconfig中,但我没有看到任何与localhost不同的异常。我制作了一份我的webconfig副本,只包含引用MySQL的部分。
`<connectionStrings>
<remove name="LocalMySqlServer" />
<add name="LocalMySqlServer" connectionString="server=localhost;password=xxxxxxxxxx;
User Id=xxxxxxxxxx;logging=True;database=xxxxxxxxxx_sec" providerName="MySql.Data.MySqlClient" />
<add name="'LocalSqlServer" connectionString="server=localhost;database=xxxxxxxxxx_CUS;
logging=True;password=xxxxxxxxxx;User Id=xxxxxxxxxxER" providerName="MySql.Data.MySqlClient" />
<remove name="LocalSqlServer" />
<add name="p10009307_cusConnectionString" connectionString="server=localhost;
User Id=xxxxxxxxxxER;password=xxxxxxxxxx;database=xxxxxxxxxx_CUS"
providerName="MySql.Data.MySqlClient" />
<add name="p10009307_cusConnectionString2" connectionString="server=localhost;
User Id=xxxxxxxxxER;password=xxxxxxxxxx;database=xxxxxxxxxx_CUS;
SQL SERVER MODE=True" providerName="MySql.Data.MySqlClient" />
</connectionStrings>
<system.data>
<DbProviderFactories>
<add name="MySQL Data Provider" invariant="MySQL.Data.MySqlClient"
description=".Net Framework Data Provider for MySQL"
type="MySQL.Data.MySqlClient.MySqlClientFactory, MySql.Data,
Version=6.4.4.0, Culture=neutral, PublicKeyToken=c5687fc88969c44d" />
</DbProviderFactories>
</system.data>
<system.web>
<customErrors mode="Off" />
<compilation targetFramework="4.0" debug="true">
<assemblies>
<add assembly="MySql.Data, Version=6.4.4.0, Culture=neutral,
PublicKeyToken=c5687fc88969c44d" />
</assemblies>
</compilation>
<authorization>
<allow roles="Admin" />
</authorization>
<authentication mode="Forms">
<forms loginUrl="~/Account/Login.aspx" timeout="2880" />
</authentication>
<membership defaultProvider="MySQLMembershipProvider">
<providers>
<clear />
<remove name="MySQLMembershipProvider" />
<add name="MySQLMembershipProvider"
type="MySql.Web.Security.MySQLMembershipProvider,
MySql.Web, Version=6.4.4.0, Culture=neutral,
PublicKeyToken=c5687fc88969c44d" applicationName="/"
description="Membership Provider"
connectionStringName="LocalMySqlServer"
writeExceptionsToEventLog="True"
autogenerateschema="True"
enablePasswordRetrieval="False"
enablePasswordReset="True"
requiresQuestionAndAnswer="False"
requiresUniqueEmail="False" passwordFormat="Clear"
maxInvalidPasswordAttempts="5" minRequiredPasswordLength="7"
minRequiredNonalphanumericCharacters="1" passwordAttemptWindow="10"
passwordStrengthRegularExpression="" />
</providers>
</membership>
<profile defaultProvider="MySQLProfileProvider">
<providers>
<clear />
<remove name="MySQLProfileProvider" />
<add name="MySQLProfileProvider" type="MySql.Web.Profile.MySQLProfileProvider,
MySql.Web, Version=6.4.4.0, Culture=neutral, PublicKeyToken=c5687fc88969c44d"
applicationName="/" description="Profile provider"
connectionStringName="LocalMySqlServer" writeExceptionsToEventLog="False"
autogenerateschema="True" />
</providers>
</profile>
<roleManager enabled="true" defaultProvider="MySQLRoleProvider">
<providers>
<clear />
<remove name="MySQLRoleProvider" />
<add applicationName="/" description="Role Provider" connectionStringName="LocalMySqlServer"
writeExceptionsToEventLog="True" autogenerateschema="True" name="MySQLRoleProvider"
type="MySql.Web.Security.MySQLRoleProvider, MySql.Web, Version=6.4.4.0, Culture=neutral,
PublicKeyToken=c5687fc88969c44d" />
</providers>
</roleManager>
<sessionState mode="Custom" cookieless="true" regenerateExpiredSessionId="true"
customProvider="MySqlSessionStateProvider">
<providers>
<add name="MySqlSessionStateProvider" type="MySql.Web.SessionState.MySqlSessionStateStore,
MySql.Web, Version=6.4.4.0, Culture=neutral, PublicKeyToken=c5687fc88969c44d"
applicationName="/" description="State Provider" connectionStringName="LocalMySqlServer"
writeExceptionsToEventLog="True" autogenerateschema="True" />
</providers>
</sessionState></system.web>
</system.webServer>
<runtime>
<assemblyBinding xmlns="urn:schemas-microsoft-com:asm.v1">
<dependentAssembly>
<assemblyIdentity name="MySql.Data" publicKeyToken="c5687fc88969c44d" />
<bindingRedirect oldVersion="0.0.0.0-6.3.7.0" newVersion="6.4.4.0" />
</dependentAssembly>
</assemblyBinding>
</runtime>
</configuration>`
此时所有东西都在运行本地主机我把DLL放在bin目录中,我不知道我错过了什么。
答案 0 :(得分:2)
我在该配置代码段中没有看到任何告诉“MySQL数据提供程序”可用的连接字符串中的哪一个。
代码中必须有一些东西告诉它conn-string名称或conn-string值。像这样:
System.Configuration.ConfigurationManager.ConnectionStrings["LocalSqlServer"].ConnectionString
此外,您的第二个conn-string在其名称前面有一个单引号字符:'LocalSqlServer
也许您不小心添加了它,现在无法通过“LocalSqlServer”的名称找到conn字符串(如果这是问题的那个,无论如何)。
答案 1 :(得分:0)
如果要使用MySQL数据库存储会话,则必须在web.config的Sessionstate中声明这一点。此外,如果设置了所有MySQL提供程序,则必须查看machine.config文件。