asp,access 标准表达式中数据类型不匹配.怎么解决?求助!!代码如下
usingSystem;usingSystem.Collections.Generic;usingSystem.Linq;usingSystem.Web;usingSys...
using System;
using System.Collections.Generic;
using System.Linq;
using System.Web;
using System.Web.UI;
using System.Web.UI.WebControls;
using System.Data.OleDb;
public partial class manager : System.Web.UI.Page
{
protected void Page_Load(object sender, EventArgs e)
{
}
protected void Button1_Click(object sender, EventArgs e)
{
string str_connection = "Provider=Microsoft.Jet.OLEDB.4.0; Data Source=";
string str_sourcefile = MapPath("~/mydb.mdb");
OleDbConnection cnn;
OleDbCommand cmd;
OleDbDataReader datar;
string str_conn = str_connection + str_sourcefile;
cnn = new OleDbConnection(str_conn);
string mid = TextBox1.Text;
string psd = TextBox2.Text;
string name = "";
string mima = "";
string sql = "select 管理员编号,密码 from 管理员表 where 管理员编号='" + mid + "'and 密码='" + psd + "'";
cnn.Open();
cmd = new OleDbCommand(sql, cnn);
datar = cmd.ExecuteReader();
while (datar.Read())
{
name = datar["管理员编号"].ToString();
mima = datar["密码"].ToString();
}
cnn.Close();
if (name != "" && mima != "")
{
Session["user"] = name;
Session["password"] = mima;
// Response.Write("<script>alert('用户名和密码正确')</script>");
Server.Transfer("mcpass.aspx");
}
else
{
Response.Write("<script>alert('管理员编号或者密码错误')</script>");
}
}
} 展开
using System.Collections.Generic;
using System.Linq;
using System.Web;
using System.Web.UI;
using System.Web.UI.WebControls;
using System.Data.OleDb;
public partial class manager : System.Web.UI.Page
{
protected void Page_Load(object sender, EventArgs e)
{
}
protected void Button1_Click(object sender, EventArgs e)
{
string str_connection = "Provider=Microsoft.Jet.OLEDB.4.0; Data Source=";
string str_sourcefile = MapPath("~/mydb.mdb");
OleDbConnection cnn;
OleDbCommand cmd;
OleDbDataReader datar;
string str_conn = str_connection + str_sourcefile;
cnn = new OleDbConnection(str_conn);
string mid = TextBox1.Text;
string psd = TextBox2.Text;
string name = "";
string mima = "";
string sql = "select 管理员编号,密码 from 管理员表 where 管理员编号='" + mid + "'and 密码='" + psd + "'";
cnn.Open();
cmd = new OleDbCommand(sql, cnn);
datar = cmd.ExecuteReader();
while (datar.Read())
{
name = datar["管理员编号"].ToString();
mima = datar["密码"].ToString();
}
cnn.Close();
if (name != "" && mima != "")
{
Session["user"] = name;
Session["password"] = mima;
// Response.Write("<script>alert('用户名和密码正确')</script>");
Server.Transfer("mcpass.aspx");
}
else
{
Response.Write("<script>alert('管理员编号或者密码错误')</script>");
}
}
} 展开
展开全部
string sql = "select 管理员编号,密码 from 管理员表 where 管理员编号='" + mid + "' and 密码='" + psd + "'";
这里应该是少了一个必要的空格,加上试试(and前面)。
追问
不是空格的错
追答
string sql = "select 管理员编号,密码 from 管理员表 where 管理员编号='" + mid + "'and 密码='" + psd + "'";
Response.Write(sql);
将sql显示出来,放到access里面执行一下看看是否正确,如果不正确,会有更详细的问题描述。
其它目测看不出问题。
已赞过
已踩过<
评论
收起
你对这个回答的评价是?
推荐律师服务:
若未解决您的问题,请您详细描述您的问题,通过百度律临进行免费专业咨询