收到错误,指出找不到连接字符串或为空。
我使用正确的连接字符串ID吗?我现在迷失了,只是在尝试我能想到的一切。
.Config连接字符串:
<connectionStrings>
<add name="DefaultConnection" connectionString="Data Source=(LocalDb)\MSSQLLocalDB;AttachDbFilename="|DataDirectory|\aspnet-HUTDMS V-2.0-20160808082503.mdf";Initial Catalog="aspnet-HUTDMS V-2.0-20160808082503";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>