连接字符串问题与嵌套网格视图Visual Studio

时间:2016-08-10 15:16:21

标签: asp.net sql-server visual-studio-2015

收到错误,指出找不到连接字符串或为空。

我使用正确的连接字符串ID吗?我现在迷失了,只是在尝试我能想到的一切。

.Config连接字符串:

     <connectionStrings>
<add name="DefaultConnection" connectionString="Data Source=(LocalDb)\MSSQLLocalDB;AttachDbFilename=&quot;|DataDirectory|\aspnet-HUTDMS V-2.0-20160808082503.mdf&quot;;Initial Catalog=&quot;aspnet-HUTDMS V-2.0-20160808082503&quot;;Integrated Security=True" providerName="System.Data.SqlClient" />
<add name="HUTDMSConnectionString" connectionString="Data Source=(LocalDB)\MSSQLLocalDB;AttachDbFilename=|DataDirectory|\HUTDMS.mdf;Integrated Security=True" providerName="System.Data.SqlClient" />
     </connectionStrings> 

下面是我的aspx页面,其中显示了我需要列出&#34; SqlDataSource&#34;的2个位置。在这种情况下它的HUTDMSConnectionString。这是我不确定HUTDMSConnectionString是否正确的地方。

AllowPaging="True"
AutoGenerateColumns="False"
DataKeyNames="CustomerID"
DataSourceID="HUTDMSConnectionString"
PageSize="20"
OnRowDataBound="GridView1_RowDataBound"
CellPadding="4"
ForeColor="#333333"
GridLines="None" OnSelectedIndexChanged="GridView1_SelectedIndexChanged">



<asp:SqlDataSource ID="HUTDMSConnectionString" runat="server"
ConnectionString="<%$ ConnectionStrings:Data Source=(LocalDB)\MSSQLLocalDB;AttachDbFilename=|DataDirectory|\HUTDMS.mdf;Integrated Security=True %>"
SelectCommand="SELECT [CourseID], [BookTitle], [Ancillary], [BookActive],[ActiveDate], [InactiveDate], [Author], [Imprint], [Publisher], [EditionAndDate], 
[tenISBN], [VendorISBN], [ebookAvailable], [eISBN], [Notes] FROM [textBooks]" OnSelecting="SqlDataSource2_Selecting">
</asp:SqlDataSource>

0 个答案:

没有答案