protected void Button1_Click(object sender, EventArgs e)
{
string UserName = this.username.Text;
string PassWord = this.password.Text;
string connstr = "provider=microsoft.jet.oledb.4.0;data source="+ Server.MapPath("zhongtian_site.mdb");
OleDbConnection conn = new OleDbConnection(connstr);
conn.Open();
int count = 0;
string sql = string.Format("select count(*) from table where userName ='{0}' and userPwd={1}",UserName ,PassWord );
SqlCommand command = new SqlCommand(sql,connstr);
try
{
conn.Open();
count = (int)command.ExecuteScalar();
if (count == 1)
{
Response.Redirect("形态中心2.aspx");
}
else
{
Response.Write("密码或帐号错误");
}
}
catch(Exception ex)
{
Response.Write("密码或帐号错误");
}
finally
{
conn.Close();
}
}
<%@ Page Language="C#" Debug="true" %>
<%@ import Namespace="System.Data" %>
<%@ import Namespace="System.Data.OleDb" %>
加断点试试 看看具体哪里的问题?