0

我已经阅读了有关此问题的所有主题,但没有找到任何问题的答案。我试过不同的连接字符串没有运气?

我尝试了很多东西,但我不知道是什么原因造成的?有没有人遇到过同样的问题并找到了解决方案?

首先是我的堆栈跟踪

堆栈跟踪:

[ArgumentException: Format of the initialization string does not conform to specification starting at index 0.]
 System.Data.Common.DbConnectionOptions.GetKeyValuePair(String connectionString, Int32 currentPosition, StringBuilder buffer, Boolean useOdbcRules, String& keyname, String& keyvalue) +5081160
 System.Data.Common.DbConnectionOptions.ParseInternal(Hashtable parsetable, String connectionString, Boolean buildChain, Hashtable synonyms, Boolean firstKey) +132
 System.Data.Common.DbConnectionOptions..ctor(String connectionString, Hashtable synonyms, Boolean useOdbcRules) +98
 System.Data.SqlClient.SqlConnectionString..ctor(String connectionString) +64
 System.Data.SqlClient.SqlConnectionFactory.CreateConnectionOptions(String connectionString, DbConnectionOptions previous) +24
 System.Data.ProviderBase.DbConnectionFactory.GetConnectionPoolGroup(String connectionString, DbConnectionPoolGroupOptions poolOptions, DbConnectionOptions& userConnectionOptions) +150
 System.Data.SqlClient.SqlConnection.ConnectionString_Set(String value) +59
 System.Data.SqlClient.SqlConnection.set_ConnectionString(String value) +4
 System.Web.UI.WebControls.SqlDataSource.CreateConnection(String connectionString) +34
 System.Web.UI.WebControls.SqlDataSourceView.ExecuteSelect(DataSourceSelectArguments arguments) +117
 System.Web.UI.DataSourceView.Select(DataSourceSelectArguments arguments, DataSourceViewSelectCallback callback) +21
 System.Web.UI.WebControls.DataBoundControl.PerformSelect() +143
 System.Web.UI.WebControls.BaseDataBoundControl.DataBind() +74
 System.Web.UI.WebControls.GridView.DataBind() +4
 System.Web.UI.WebControls.BaseDataBoundControl.EnsureDataBound() +66
 System.Web.UI.WebControls.CompositeDataBoundControl.CreateChildControls() +75
 System.Web.UI.Control.EnsureChildControls() +102
 System.Web.UI.Control.PreRenderRecursiveInternal() +42
 System.Web.UI.Control.PreRenderRecursiveInternal() +175
 System.Web.UI.Control.PreRenderRecursiveInternal() +175
 System.Web.UI.Page.ProcessRequestMain(Boolean includeStagesBeforeAsyncPoint, Boolean includeStagesAfterAsyncPoint) +2496

网页配置

  <connectionStrings>
  <add name="riktigaconnstringen" connectionString="Data Source=aspx-XXXXX.mssql.binero.se;Initial Catalog=XXXX-aspx;Persist Security Info=True;User ID=XXXX;Password=XXXXX"/>

和我的页面

 <asp:SqlDataSource 
        ID="test1" 
        runat="server" 
        DataSourceMode="DataSet"
        SelectCommand="SELECT * FROM t_produkter"
        ConnectionString="<% ConnectionStrings:riktigaconnstringen %>"></asp:SqlDataSource>
 </connectionStrings>
4

1 回答 1

2

我不确定这是否是您的问题的原因,但在 SqlDataSource 的 MSDN 示例中,我可以看到引用 ConnectionString 的不同语法

  <asp:SqlDataSource
      ID="test1"   
      runat="server"   
      DataSourceMode="DataSet"  
      SelectCommand="SELECT * FROM t_produkter"  
      ConnectionString="<%$ ConnectionStrings:riktigaconnstringen %>"></asp:SqlDataSource
  </asp:SqlDataSource>

注意$后面的字符<%

于 2012-06-27T23:29:54.343 回答