asp.net - 如何修复错误::初始化字符串的格式不符合从索引 0 开始的规范::

标签 asp.net connection-string

我在 godaddy 共享主机上上传了我的网站。我可以从我的管理工作室访问该数据库。我无法从我的网站访问该数据库。我收到以下错误:

Format of the initialization string does not conform to specification starting at index 0.

我的连接字符串位于 web.config 中,如下所示:

<connectionStrings>
    <add name="mcn" connectionString="Data Source=mydatabase.db.8706856.hostedresource.com; Initial Catalog=mydatabase; User ID=username; Password=xyz;" providerName="System.Data.SqlClient" />    
</connectionStrings>

什么原因导致这个错误?我还尝试编写 ...Data Source=(local);...

最佳答案

查看实际的连接字符串可能会有所帮助。添加到Global.asax:

throw new Exception(ConfigurationManager.ConnectionStrings["mcn"].ConnectionString);

如果实际的连接字符串是$(ReplacableToken_mcn-Web.config Connection String_0),那就可以解释问题了。

关于asp.net - 如何修复错误::初始化字符串的格式不符合从索引 0 开始的规范::,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/9040266/

相关文章:

c# - 更新 Entity Framework 中的实体

php - 有什么方法可以将 asp.net 与 php 集成?

postgresql - 网络配置 : Connection String with Application name

java - 带有 JDBC 的 Advantage 数据库本地服务器

encryption - 在经典ASP中加密连接字符串

asp.net - 如何在aspx(javascript)中找到控件在模板中的ClientId

asp.net - 分支 ASP.NET Core 管道身份验证

asp.net - 表单提交后如何清除asp.net页面中的所有数据

C# MySQL 无法识别输入

c# - 无法从 pocketpc (windows mobile 6) 打开到 SQL Server 2005 的连接