using System;
using System.Collections;
using System.ComponentModel;
using System.Data;
using System.Drawing;
using System.Web;
using System.Web.SessionState;
using System.Web.UI;
using System.Web.UI.WebControls;
using System.Web.UI.HtmlControls;
using System.Data.OleDb;namespace gongshu
{
/// <summary>
/// Login 的摘要说明。
/// </summary>
public class Login : System.Web.UI.Page
{
protected System.Web.UI.WebControls.TextBox TB_No;
protected System.Web.UI.WebControls.Button BT_Submit;
protected System.Web.UI.WebControls.Button BT_Cancel;
protected System.Web.UI.WebControls.TextBox TB_Pass;
private void Page_Load(object sender, System.EventArgs e)
{
Response.Write("fsdjgfusdgf");
// 在此处放置用户代码以初始化页面
} #region Web 窗体设计器生成的代码
override protected void OnInit(EventArgs e)
{
//
// CODEGEN: 该调用是 ASP.NET Web 窗体设计器所必需的。
//
InitializeComponent();
base.OnInit(e);
}
/// <summary>
/// 设计器支持所需的方法 - 不要使用代码编辑器修改
/// 此方法的内容。
/// </summary>
private void InitializeComponent()
{
this.BT_Submit.Click += new System.EventHandler(this.BT_Submit_Click);
this.Load += new System.EventHandler(this.Page_Load); }
#endregion private void BT_Submit_Click(object sender, System.EventArgs e)
{
Page.Response.Write("fsdjgfusdgf");
string strconn="Provider=Microsoft.Jet.OLEDB.4.0;Data Source="+Server.MapPath("./")+"table.mdb";
OleDbConnection conn=new OleDbConnection(strconn);
// OleDbConnection conn=new OleDbConnection("Provider=Microsoft.Jet.OLEDB.4.0;Data Source="+Server.MapPath("./")+"table.mdb;");
string selectstr="select No from Use where No='"+TB_No.Text+"' and Password='"+TB_Pass.Text+"'";
OleDbCommand mycommand=new OleDbCommand(selectstr,conn);
Page.Response.Write(selectstr);
OleDbDataReader dr;
conn.Open();
TB_No.Text="123";
dr=mycommand.ExecuteReader();
while(dr.Read())
{
Session["No"]=TB_No.Text;
Response.Redirect("Aframe.htm");
}
TB_No.Text="123";
TB_Pass.Text="";
}
}
}
using System.Collections;
using System.ComponentModel;
using System.Data;
using System.Drawing;
using System.Web;
using System.Web.SessionState;
using System.Web.UI;
using System.Web.UI.WebControls;
using System.Web.UI.HtmlControls;
using System.Data.OleDb;namespace gongshu
{
/// <summary>
/// Login 的摘要说明。
/// </summary>
public class Login : System.Web.UI.Page
{
protected System.Web.UI.WebControls.TextBox TB_No;
protected System.Web.UI.WebControls.Button BT_Submit;
protected System.Web.UI.WebControls.Button BT_Cancel;
protected System.Web.UI.WebControls.TextBox TB_Pass;
private void Page_Load(object sender, System.EventArgs e)
{
Response.Write("fsdjgfusdgf");
// 在此处放置用户代码以初始化页面
} #region Web 窗体设计器生成的代码
override protected void OnInit(EventArgs e)
{
//
// CODEGEN: 该调用是 ASP.NET Web 窗体设计器所必需的。
//
InitializeComponent();
base.OnInit(e);
}
/// <summary>
/// 设计器支持所需的方法 - 不要使用代码编辑器修改
/// 此方法的内容。
/// </summary>
private void InitializeComponent()
{
this.BT_Submit.Click += new System.EventHandler(this.BT_Submit_Click);
this.Load += new System.EventHandler(this.Page_Load); }
#endregion private void BT_Submit_Click(object sender, System.EventArgs e)
{
Page.Response.Write("fsdjgfusdgf");
string strconn="Provider=Microsoft.Jet.OLEDB.4.0;Data Source="+Server.MapPath("./")+"table.mdb";
OleDbConnection conn=new OleDbConnection(strconn);
// OleDbConnection conn=new OleDbConnection("Provider=Microsoft.Jet.OLEDB.4.0;Data Source="+Server.MapPath("./")+"table.mdb;");
string selectstr="select No from Use where No='"+TB_No.Text+"' and Password='"+TB_Pass.Text+"'";
OleDbCommand mycommand=new OleDbCommand(selectstr,conn);
Page.Response.Write(selectstr);
OleDbDataReader dr;
conn.Open();
TB_No.Text="123";
dr=mycommand.ExecuteReader();
while(dr.Read())
{
Session["No"]=TB_No.Text;
Response.Redirect("Aframe.htm");
}
TB_No.Text="123";
TB_Pass.Text="";
}
}
}
解决方案 »
- 中英双语网站
- 如何做到程序间的数据交换,必须不读硬盘的交换
- 书《亲密接触ASP.NET》P160页例题:为何不能在VS写成两个文件
- 关于DataReader读值的问题?
- 向方法传OleDbConnection参数,为什么这个连接被引用而不是方法内建立副本?
- |M| CSDN新版的功能中的JS实现 一个是列表中的鼠标的淡入淡出 一个是给分时的那个DIV的显示和隐藏的淡入淡出 麻烦大家给个源码 谢谢
- 急:问web叶面上的treeview怎么跟数据库绑定?
- 如何使DataGrid可以做到任意列取数?
- 开发模式的选择
- ASP.NET 中的上传文件能有多大,有什么限制
- 急,在线等!1
- 有谁在web中用过dsoframer.ocx?
下次贴代码,记得将aspx文件也传上来。
我试过,
找不到文件 'E:\Inetpub\Inetpub_Gb\wwwroot\DataGridStudy\table.mdb'。
说明: 执行当前 Web 请求期间,出现未处理的异常。请检查堆栈跟踪信息,以了解有关该错误以及代码中导致错误的出处的详细信息。 异常详细信息: System.Data.OleDb.OleDbException: 找不到文件 'E:\Inetpub\Inetpub_Gb\wwwroot\DataGridStudy\table.mdb'。源错误:
行 63:
行 64: OleDbDataReader dr;
行 65: conn.Open();
行 66: TB_No.Text="123";
行 67: dr=mycommand.ExecuteReader();
在conn.Open();这一行出错,因为没有table.mdb这个文件
this.BT_Submit.Click += new System.EventHandler(this.BT_Submit_Click);
添加到private void InitializeComponent()里
时间也没有丢失。
只能看看你的.aspx文件
<%@ Page %>里面有没有AutoEventWireup="True" 有的话改成 AutoEventWireup="False"
如果还是不行,你把代码都贴出来。前后台的代码。