using System;
using System.Data;
using System.Configuration;
using System.Collections;
using System.Web;
using System.Web.Security;
using System.Web.UI;
using System.Web.UI.WebControls;
using System.Web.UI.WebControls.WebParts;
using System.Data.Odbc;public partial class dlZC_denglu : System.Web.UI.Page
{
protected void Page_Load(object sender, EventArgs e)
{
if (!Page.IsPostBack)
{ //产生验证码
int i_rand;
Random r = new Random();
i_rand = r.Next(1000, 9999);
Label1.Text = i_rand.ToString();
}
}
protected void Button1_Click1(object sender, EventArgs e)
{
if (IsValid)
{
string username,password,val;
val = TextBox3.Text.Trim();
if (val != Label1.Text)
{
Response.Write("<script>alert('验证码错误,请重新输入!');</script>");
}
else
{
username = TextBox1.Text.Trim();
password = TextBox2.Text.Trim();
OdbcConnection conn = null;
OdbcCommand com = null;
OdbcDataReader dr = null;
conn = new OdbcConnection("PROVIDER=Microsft.Jet.OLEDB.4.0;DATA Source="+Server.MapPath("../App_Data/新建 Microsoft Office Access 应用程序.mdb"));
conn.Open();
com = new OdbcCommand("select * from [zhuc] where zhuc_username='" + username + "' and zhuc_password='" + password + "'", conn);
dr = com.ExecuteReader();
if (dr.Read())
{
Response.Write("<script>alert('注册成功');window.location.href='../xinqing.aspx';</script>");
}
else
{
Response.Write("<script>alert('失败!');</script>");
}
}
}
}
}
using System.Data;
using System.Configuration;
using System.Collections;
using System.Web;
using System.Web.Security;
using System.Web.UI;
using System.Web.UI.WebControls;
using System.Web.UI.WebControls.WebParts;
using System.Data.Odbc;public partial class dlZC_denglu : System.Web.UI.Page
{
protected void Page_Load(object sender, EventArgs e)
{
if (!Page.IsPostBack)
{ //产生验证码
int i_rand;
Random r = new Random();
i_rand = r.Next(1000, 9999);
Label1.Text = i_rand.ToString();
}
}
protected void Button1_Click1(object sender, EventArgs e)
{
if (IsValid)
{
string username,password,val;
val = TextBox3.Text.Trim();
if (val != Label1.Text)
{
Response.Write("<script>alert('验证码错误,请重新输入!');</script>");
}
else
{
username = TextBox1.Text.Trim();
password = TextBox2.Text.Trim();
OdbcConnection conn = null;
OdbcCommand com = null;
OdbcDataReader dr = null;
conn = new OdbcConnection("PROVIDER=Microsft.Jet.OLEDB.4.0;DATA Source="+Server.MapPath("../App_Data/新建 Microsoft Office Access 应用程序.mdb"));
conn.Open();
com = new OdbcCommand("select * from [zhuc] where zhuc_username='" + username + "' and zhuc_password='" + password + "'", conn);
dr = com.ExecuteReader();
if (dr.Read())
{
Response.Write("<script>alert('注册成功');window.location.href='../xinqing.aspx';</script>");
}
else
{
Response.Write("<script>alert('失败!');</script>");
}
}
}
}
}
解决方案 »
- 急救!!!c#串口编程!!!!!!!!!!!!!!!!!!!!!!!!
- 一个进程执行后台执行一个安装文件.exe或者.msi 那么进程结束时怎么捕获运行状态呢,成功,失败?
- C#应用程式把jpg图片转化为tif(急)
- 主明細表問題????????????
- 各位,问个几何的问题
- 对象引用到实例,如何改动这段代码?
- 将网页保存在SqlServer中后提取出来将其赋值于Label,为何没有网页的原有格式?请问:如何将其从数据库提取后保持原有格式?
- xslt如何判断前一个数据是否等于下一个数据
- 开机自动启动winform程序
- oracle建表的问题?
- 怎么改啊,菜鸟求救,提示错误是最后的discount变量是未赋值的局部变量
- C#向表中插入一条记录都有哪些做法?最快捷的是什么方式?
<add name="accessConnStr" connectionString="Provider=Microsoft.Jet.OLEDB.4.0; Data Source= |DataDirectory|a.mdb" providerName="System.Data.OleDb"/> <appSettings>
<add key="ConnString" value="provider=microsoft.jet.oledb.4.0;data source="/>
<add key="dbPath" value="~/App_Data/a.mdb"/>
</appSettings>
ERROR [IM002] [Microsoft][ODBC 驱动程序管理器] 未发现数据源名称并且未指定默认驱动程序
说明: 执行当前 Web 请求期间,出现未处理的异常。请检查堆栈跟踪信息,以了解有关该错误以及代码中导致错误的出处的详细信息。 异常详细信息: System.Data.Odbc.OdbcException: ERROR [IM002] [Microsoft][ODBC 驱动程序管理器] 未发现数据源名称并且未指定默认驱动程序源错误:
行 43: conn = new OdbcConnection("Provider=Microsoft.Jet.OLEDB.4.0;Data Source=|DataDirectory|yonghuzhuc.mdb;Persist Security Info=True");
行 44:
行 45: conn.Open();
行 46: com = new OdbcCommand("select * from [zhuc] where zhuc_username='" + username + "' and zhuc_password='" + password + "'", conn);
行 47: dr = com.ExecuteReader();
源文件: f:\biyeshijie\feel\dlZC\denglu.aspx.cs 行: 45 这个!!请再次指教!!
username = TextBox1.Text.Trim();
password = TextBox2.Text.Trim();
OleDbDataReader dr;
OleDbConnection con = null;
OleDbCommand cmd = null;
con = new OleDbConnection("PROVIDER=Microsoft.Jet.OLEDB.4.0;DATA Source=" + Server.MapPath("~/App_Data/yonghuzhuc.mdb"));
strSql = "select username,role from [zhuc] where username='" + username + "' and password='" + password + "'";
cmd = new OleDbCommand(strSql, con);
try
{
con.Open();
dr = cmd.ExecuteReader();
if (dr.Read())
{
username = dr["username"].ToString();
role = dr["role"].ToString();
FormsAuthentication.RedirectFromLoginPage(username, false);
if (role == "1")//System
{ Response.Redirect("dlzc/liuy.aspx");
}
else
Response.Redirect("xinqing.aspx");
} }
catch (Exception exc)
{
string msg;
msg = exc.Message + "添加出错,请跟管理员联系!";
Response.Write(msg); }
finally
{
}
}
请问这里那里有错??不能够正常跳转到其他页面!!
如果还不行,检查你的yonghuzhuc是否拼写错误。如果再不行,下载安装这个
http://www.microsoft.com/downloads/details.aspx?FamilyID=6c050fe3-c795-4b7d-b037-185d0506396c&DisplayLang=zh-cnhttp://www.microsoft.com/downloads/details.aspx?familyid=78CAC895-EFC2-4F8E-A9E0-3A1AFBD5922E&displaylang=zh-cn另外,你的系统必须是32位的,不能是64位的,64位必须以32位运行