异常详细信息: System.Data.OleDb.OleDbException: 至少一个参数没有被指定值。急急急~菜鸟学习
using System;
using System.Collections;
using System.ComponentModel;
using System.Data;
using System.Drawing;
using System.Web;
using System.Web.SessionState;
using System.Web.Security;
using System.Web.UI;
using System.Web.UI.WebControls;
using System.Web.UI.HtmlControls;
using System.Web.UI.WebControls.WebParts;
using System.Data.OleDb;
using System.Configuration;
public partial class _Default: System.Web.UI.Page
{
protected System.Web.UI.WebControls.RequiredFieldValidator rfvUserid;
protected System.Web.UI.WebControls.RequiredFieldValidator rfvPwd;
public string strConnection;
OleDbConnection myConn;
public _Default()
{
Page.Init += new System.EventHandler(Page_Init);
}
private void Page_Load(object sender, System.EventArgs e)
{
}
private void Page_Init(object sender, EventArgs e)
{
InitializeComponent();
string strConnection = "Provider=Microsoft.Jet.OLEDB.4.0; Data Source=" + Server.MapPath(".") + "..\\personal.mdb;";
//personal.mdb放在与aspx文件同一目录下
myConn = new OleDbConnection(strConnection);
}
private void InitializeComponent() //InitializeComponent()的意思是初始化窗口或者控件
{
this.LogButton.Click += new System.EventHandler(this.LogButton_Click);
this.Load += new System.EventHandler(this.Page_Load);
}
private void LogButton_Click(object sender, System.EventArgs e)
{
string UserName,Userpsd;
UserName=Userid.Text;
Userpsd=Pwd.Text;
string mySel = "SELECT count(*) as iCount from User_tb where Userid='" +UserName+ "'";
OleDbCommand myCmd1=new OleDbCommand(mySel,myConn);
myCmd1.Connection.Open();
OleDbDataReader Dr1;
Dr1=myCmd1.ExecuteReader();
Dr1.Read();
string Count=Dr1["iCount"].ToString();
Dr1.Close();
myCmd1.Connection.Close();
string DrPwd,DrRoles;
if(Count!="0")
{
mySel="SELECT * from User_tb where ID='"+UserName+"'";
OleDbCommand myCmd=new OleDbCommand(mySel,myConn);
myCmd.Connection.Open();
OleDbDataReader Dr;
Dr=myCmd.ExecuteReader();
Dr.Read();
DrPwd = Dr["UserPsd"].ToString();
Dr.Close();
if(DrPwd==Userpsd)
{
Session["ID"]=UserName;//新建一个Session
Response.Redirect("Default.aspx");
}
else
Msg.Text="登录密码错.";
}
else
Msg.Text="没有这个用户.";
}
}
错误报告:
至少一个参数没有被指定值。
说明: 执行当前 Web 请求期间,出现未处理的异常。请检查堆栈跟踪信息,以了解有关该错误以及代码中导致错误的出处的详细信息。
异常详细信息: System.Data.OleDb.OleDbException: 至少一个参数没有被指定值。
源错误:
只有在调试模式下进行编译时,生成此未处理异常的源代码才会显示出来。若要启用此功能,请执行以下步骤之一,然后请求 URL:
1. 在产生错误的文件的顶部添加一条“Debug=true”指令。例如:
<%@ Page Language="C#" Debug="true" %>
或:
2. 将以下的节添加到应用程序的配置文件中:
<configuration>
<system.web>
<compilation debug="true"/>
</system.web>
</configuration>
请注意,第二个步骤将使给定应用程序中的所有文件在调试模式下进行编译;第一个步骤仅使该特定文件在调试模式下进行编译。
重要事项: 以调试模式运行应用程序一定会产生内存/性能系统开销。在部署到生产方案之前,应确保应用程序调试已禁用。
请各位大虾能尽快给出答案,小弟不胜感激!超级着急~