I'm working on a program and when I try to run it, I am receiving an error stating "The connection name 'ConnectionString' was not found in the applications configuration or the connection string is empty." Here is my code:

<%@ Page Language="VB" AutoEventWireup="false" CodeFile="CustomerDisplay.aspx.vb" Inherits="CustomerDisplay" %>

<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">

<html xmlns="http://www.w3.org/1999/xhtml" >
<head runat="server">
    <title>Project 1-B: Create Contact List</title>
    <link href="StyleSheet.css" rel="stylesheet" type="text/css" />
</head>
<body>
    <form id="form1" runat="server">
    <div>
        <span style="font-size: 48pt; color: blue; font-family: Arial"><strong>
        <em style="font-family: Arial, Helvetica, sans-serif; font-size: inherit; font-weight: bold; font-style: italic; color: #0000FF">SportsPro</em></strong></span><br />
        <span style="font-size: xx-large; color: #FF0000; font-family: 'Times New Roman', Times, serif; ">Sports management software for the sports
            enthusiast</span><br />
        <br />
        <br />
        Select a customer:&nbsp;
        <asp:DropDownList ID="ddlCustomers" runat="server" AutoPostBack="True" 
            DataSourceID="AccessDataSource1" DataTextField="CustomerID" 
            DataValueField="CustomerID">
        </asp:DropDownList>
        <br />
        <br />
        <div id="customer" style="border: medium double #00FF00" >
         <br />
        <br />
        <table>
            <tr>
                <td style="width: 72px">
                    Name</td>
                <td style="width: 170px">
                    <asp:Label ID="lblName" runat="server" Text="lblName" Visible="False"></asp:Label>
                </td>
            </tr>
            <tr>
                <td style="width: 72px">
                    Address:</td>
                <td style="width: 170px">
                    <asp:Label ID="lblAddress" runat="server"></asp:Label></td>
            </tr>
            <tr>
                <td style="width: 72px">
                    </td>
                <td style="width: 170px">
                    <asp:Label ID="lblCityStateZip" runat="server"></asp:Label></td>
            </tr>
            <tr>
                <td style="width: 72px">
                    Phone:</td>
                <td style="width: 170px">
                    <asp:Label ID="lblPhone" runat="server"></asp:Label></td>
            </tr>
            <tr>
                <td style="width: 72px">
                    Email:</td>
                <td style="width: 170px">
                    <asp:Label ID="lblEmail" runat="server"></asp:Label></td>
            </tr>
        </table>
         <br />
        <br />
        </div>
        
        <br />
        <asp:Button ID="btnAdd" runat="server" Text="Add to Contact List" Width="144px" />&nbsp;
        <asp:Button ID="btnDisplay" runat="server" Text="Display Contact List"
            Width="144px" />
        <asp:AccessDataSource ID="AccessDataSource1" runat="server" 
            DataFile="~/App_Data/TechSupport.mdb" SelectCommand="SELECT * FROM [Customers]">
        </asp:AccessDataSource>
        <asp:AccessDataSource ID="AccessDataSource2" runat="server" 
            DataFile="~/App_Data/TechSupport.mdb" 
            SelectCommand="SELECT [Name], [Address], [City], [State], [ZipCode], [Phone], [Email] FROM [Customers] WHERE ([CustomerID] = ?)">
            <SelectParameters>
                <asp:ControlParameter ControlID="ddlCustomers" Name="CustomerID" 
                    PropertyName="SelectedValue" Type="Int32" />
            </SelectParameters>
        </asp:AccessDataSource>
        <asp:SqlDataSource ID="SqlDataSource1" runat="server" 
            ConnectionString="<%$ ConnectionStrings:ConnectionString %>" 
            DeleteCommand="DELETE FROM [Table1] WHERE [CustomerID] = @original_CustomerID" 
            InsertCommand="INSERT INTO [Table1] ([CustomerID]) VALUES (@CustomerID)" 
            OldValuesParameterFormatString="original_{0}" 
            SelectCommand="SELECT [CustomerID] FROM [Table1] WHERE ([CustomerID] = @CustomerIDs)">
            <SelectParameters>
                <asp:ControlParameter ControlID="ddlCustomers" Name="CustomerIDs" 
                    PropertyName="SelectedValue" />
            </SelectParameters>
            <DeleteParameters>
                <asp:Parameter Name="original_CustomerID" Type="Decimal" />
            </DeleteParameters>
            <InsertParameters>
                <asp:ControlParameter ControlID="ddlCustomers" Name="CustomerID" 
                    PropertyName="SelectedValue" Type="Decimal" />
            </InsertParameters>
        </asp:SqlDataSource>
        <br />
        </div>
    </form>
</body>
</html>

Can someone please help me?

Recommended Answers

All 2 Replies

Ok in the SqlDataSource1 this part of it.
"ConnectionString="<%$ ConnectionStrings:ConnectionString %>""
basically its looking the web.config file in the section ConnectionString should be a connection called "ConnectionString".
verify if that is true.

check your Web.config>>ConnectionString

you must Have:

<configuration>
<connectionStrings>
    <clear/>
    <add providerName="" name="" connectionString=""/>
  </connectionStrings>
Be a part of the DaniWeb community

We're a friendly, industry-focused community of developers, IT pros, digital marketers, and technology enthusiasts meeting, networking, learning, and sharing knowledge.