日期:2014-05-20  浏览次数:20977 次

.net 配置文件连接数据库出错
http://msdn.microsoft.com/zh-cn/library/taab950e(v=vs.100).aspx
我按照这个网站写了个简单例程,在连接数据库的配置上出错了
不懂是哪里出错,请熟悉的人指导,谢谢。

报错如下:


aspx的代码如下:

<%@ Page Language="vb" AutoEventWireup="false" CodeBehind="test_profile.aspx.vb" Inherits="test_profile.test_profile" %>

<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<script runat ="server" >
    Sub Page_Load(ByVal sender As Object, ByVal e As EventArgs)
        labelPostalCode.Text = Profile.PostalCode
    End Sub
    
    Sub SetPostalCode_Click(ByVal sender As Object, _
            ByVal e As System.EventArgs)
        Profile.PostalCode = Server.HtmlEncode(textPostalCode.Text)
        labelPostalCode.Text = Profile.PostalCode
    End Sub
    
</script>
<html xmlns="http://www.w3.org/1999/xhtml">
<head runat="server">
    <title></title>
</head>
<body>
    <form id="form1" runat="server">
    <div>
        <asp:TextBox ID="textPostalCode" runat="server"></asp:TextBox>
        <asp:Button ID="SetPostalCode" runat="server" Text="Button" OnClick="SetPostalCode_Click"
/>
        <asp:Label ID="labelPostalCode" runat="server" Text="Label"></asp:Label>
    </div>
    </form>
</body>
</html>

web.congfig文件如下:

<?xml version="1.0" encoding="utf-8"?>

<!--
  有关如何配置 ASP.NET 应用程序的详细信息,请访问
  http://go.microsoft.com/fwlink/?LinkId=169433
  -->

<configuration>
  <connectionStrings>
    <add name="LocalSqlServer"
       connectionString="server=PC-20121108IOLX;database=test_profile;Integrated Security=SSPI;"
       providerName="System.Data.SqlClient"
   />
  </connectionStrings>

  <system.web>
    <compilation debug="true" strict="false" explicit="true" targetFramework="4.0" />
    <anonymousIdentification enabled="true" />
    <profile>
      <properties>
        <add name="PostalCode"         type="System.String"         allowAnonymous="true" />
      </properties>
    </profile>

    <!-- other Web.config settings here -->
  </system.web>

</configuration>