| 网站首页 | 业界新闻 | 小组 | 威客 | 人才 | 下载频道 | 博客 | 代码贴 | 在线编程 | 编程论坛
欢迎加入我们,一同切磋技术
用户名:   
 
密 码:  
共有 1169 人关注过本帖
标题:ConnectionString 属性尚未初始化。
只看楼主 加入收藏
wstpx
Rank: 1
等 级:新手上路
帖 子:1
专家分:0
注 册:2008-10-26
收藏
 问题点数:0 回复次数:0 
ConnectionString 属性尚未初始化。
ConnectionString 属性尚未初始化。
说明: 执行当前 Web 请求期间,出现未处理的异常。请检查堆栈跟踪信息,以了解有关该错误以及代码中导致错误的出处的详细信息。

异常详细信息: System.InvalidOperationException: ConnectionString 属性尚未初始化。

源错误:


行 28:       end if
行 29:            conn=new oledbconnection()
行 30:            conn.open()
行 31:            com=new oledbcommand(comstr,conn)
行 32:            dim rd as oledbdatareader
 

源文件: D:\My Documents\My Web Sites\mysite2\login.aspx    行: 30

堆栈跟踪:


[InvalidOperationException: ConnectionString 属性尚未初始化。]
   System.Data.OleDb.OleDbConnection.PermissionDemand() +46
   System.Data.OleDb.OleDbConnectionFactory.PermissionDemand(DbConnection outerConnection) +22
   System.Data.ProviderBase.DbConnectionClosed.OpenConnection(DbConnection outerConnection, DbConnectionFactory connectionFactory) +89
   System.Data.OleDb.OleDbConnection.Open() +19
   ASP.login_aspx.onlogin_click(Object sender, EventArgs e) in D:\My Documents\My Web Sites\mysite2\login.aspx:30
   System.Web.UI.WebControls.Button.OnClick(EventArgs e) +75
   System.Web.UI.WebControls.Button.RaisePostBackEvent(String eventArgument) +97
   System.Web.UI.WebControls.Button.System.Web.UI.IPostBackEventHandler.RaisePostBackEvent(String eventArgument) +7
   System.Web.UI.Page.RaisePostBackEvent(IPostBackEventHandler sourceControl, String eventArgument) +11
   System.Web.UI.Page.RaisePostBackEvent(NameValueCollection postData) +33
   System.Web.UI.Page.ProcessRequestMain(Boolean includeStagesBeforeAsyncPoint, Boolean includeStagesAfterAsyncPoint) +491

下面是完整代码
 <%@ Page Language="vb" Debug="true" %>
<%@ Import Namespace="system.data" %>
<%@ Import Namespace="system.data.oledb" %>
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.

<html dir="ltr" xmlns="http://www.

<head runat="server">
<meta http-equiv="Content-Type" content="text/html; charset=utf-8" />
<title>管理员登录</title>
<script language="vb" runat="server" type="text/vb" id="script1">
          dim conn as new oledbconnection
    sub page_load(sender as object,e as eventargs)
          dim constr As String
          dim data=(ConfigurationSettings.AppSettings("data"))
           constr="Provider=Microsoft Jet 4.0 OLE DB provider;Data Source="&server.MapPath (data)
          conn.connectionstring=constr
          '数据库连接
     end sub
     Sub onlogin_click(sender As Object, e As EventArgs)
         dim com as oledbcommand
         dim comstr As String
         comstr="select 用户名,密码 from admin where 用户名='"
         comstr=comstr & trim(username.text) & "'and 密码='" & trim(password.text) & "'"
         if username.text="" or Instr(username.text,"=")>0 or Instr(username.text,"%")>0 or Instr(username.text,chr(32))>0 or Instr(username.text,"?")>0 or Instr(username.text,"&")>0 or Instr(username.text,";")>0 or Instr(username.text,",")>0 or Instr(username.text,"'")>0 or Instr(username.text,",")>0 or Instr(username.text,chr(34))>0 or Instr(username.text,chr(9))>0 or Instr(username.text," ")>0 or Instr(username.text,"$")>0 then
         response.write("出错啦...请不要输入非法的字符!")
         response.end
      end if
           conn=new oledbconnection()
           conn.open()
           com=new oledbcommand(comstr,conn)
           dim rd as oledbdatareader
           rd=com.executereader()
           if not rd.read() then
           message.text="用户名或密码错误!"
           rd.close
           conn.close
           exit sub
           else
           session("username")="username.text"
           session("password")="password.text"
           session.timeout="60"
           response.redirect("manage.aspx")
           rd.close
           conn.close
           end if
       end sub
       Sub onreset_click(sender As Object, e As EventArgs)
           username.text=""
           password.text=""
       end sub
    </script>
<style type="text/css">
.style1 {
    font-weight: normal;
    text-align: center;
}
.style2 {
    text-align: center;
}
</style>
</head>

<body>

<form id="form1" runat="server">
    <h1 class="style1">&nbsp;</h1>
    <h1 class="style1">&nbsp;</h1>
    <h1 class="style1">&nbsp;</h1>
    <h1 class="style1">&nbsp;<strong>管理员登录</strong></h1>
    <p class="style2">
    <asp:Label runat="server" Text="用户名" id="Label1"></asp:Label>
    <strong>&nbsp;
    <asp:TextBox runat="server" id="username"></asp:TextBox>
    </strong></p>
    <p class="style2"><strong>&nbsp;
    <asp:Label runat="server" Text="密码" id="Label2"></asp:Label>
&nbsp;
    <asp:TextBox runat="server" id="password"></asp:TextBox>
    </strong></p>
    <div class="style2">
        <p>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;
    <asp:Button runat="server" Text="登录" id="Button1" OnClick="onlogin_click" Width="40px"/>
        &nbsp;&nbsp;&nbsp;&nbsp;&nbsp;
    <asp:Button runat="server" Text="重置" id="Button2" OnClick="onreset_click"/>
        </p>
        <p>
        <asp:Label runat="server" Text="" id="message"></asp:Label>
        </p>
    </div>
</form>

</body>

</html>

编辑平台是Expression Web,请高手帮忙,拜谢了!!-_-
搜索更多相关主题的帖子: 属性 
2008-10-26 10:39
快速回复:ConnectionString 属性尚未初始化。
数据加载中...
 
   



关于我们 | 广告合作 | 编程中国 | 清除Cookies | TOP | 手机版

编程中国 版权所有,并保留所有权利。
Powered by Discuz, Processed in 0.021909 second(s), 7 queries.
Copyright©2004-2024, BCCN.NET, All Rights Reserved