OleDbConnection con=new OleDbConnection("Provider=Microsoft.Jet.OleDb.4.0;Data Source="+Server.MapPath("/wunjuonline/database/wunjuDB.mdb"));
con.Open();
OleDbCommand cmd=new OleDbCommand("select * from productTable where proudctID='9'",con);
OleDbDataReader odr=cmd.ExecuteReader();//就这一句报错。
odr.Read();错误提示:
说明: 执行当前 Web 请求期间,出现未处理的异常。请检查堆栈跟踪信息,以了解有关该错误以及代码中导致错误的出处的详细信息。 异常详细信息: System.Data.OleDb.OleDbException: 至少一个参数没有被指定值。
con.Open();
OleDbCommand cmd=new OleDbCommand("select * from productTable where proudctID='9'",con);
OleDbDataReader odr=cmd.ExecuteReader();//就这一句报错。
odr.Read();错误提示:
说明: 执行当前 Web 请求期间,出现未处理的异常。请检查堆栈跟踪信息,以了解有关该错误以及代码中导致错误的出处的详细信息。 异常详细信息: System.Data.OleDb.OleDbException: 至少一个参数没有被指定值。
解决方案 »
- gridview翻页错误怎么也解决不了?
- vs2010不编译了,什么毛病?
- StreamWriter streamWriter = new StreamWriter(Response.OutputStream);提问
- 火狐下的问题还真麻烦
- 运行一个asp.net ajax网站,服务器软件方面有些什么要求?
- 关于设定GridView中格式字符串和链接问题?
- 为什么分页不成功啊!!!
- 急!!!求一真实有效的Microsoft Visual Studio.NET 2003下载地址。
- 难道JMAIL也要用Windows自带的MailServer(STMP虚拟服务器)
- ASP.NET部署后调用动态库失败
- SQL与asp.net连接, 运行后出现"创建锁错误",WEB什么也不显示!
- 一个aspx页面里面用了两个button 还用了一些验证控件 我想点其中一个button ,其中一些验证控件不起作用
要這樣寫:
OleDbDataReader odr;
odr=cmd.ExecuteReader();
--->改为
OleDbDataReader odr=cmd.ExecuteReader(CommandBehavior.CloseConnection);
说明:这是一个用户控件
//控件属性
private string pID="";
public string productID
{
set
{
this.pID=value;
}
}
//page_load()事件中代码,
{
OleDbConnection con=new OleDbConnection("Provider=Microsoft.Jet.OleDb.4.0;Data Source="+Server.MapPath("/wunjuonline/database/wunjuDB.mdb"));
con.Open();
OleDbCommand cmd=new OleDbCommand("select * from productTable where proudctID='"+pID+"'",con);
OleDbDataReader odr=cmd.ExecuteReader();//这一句错,错误提示如题
odr.Read();
this.lblNo.Text=odr.GetString(0).ToString();
this.lblName.Text=odr.GetString(2).ToString();
this.lblPrice.Text=odr.GetString(3).ToString();
this.photo.ImageUrl="/wunjuonline/images/"+odr.GetString(4);
this.txtQty.Text="0";
this.hlkOrder.NavigateUrl="/wunjuonline/order.aspx?id="+lblNo.Text;
}我是在一个页面中加载这个用户控件时出错的,经跟踪测试,属性值也正确传进来了,
跟踪 cmd.CommandText的值,也正确(sql语句为:select * from productTable where typeID='2b1')
我搞不懂那句为何执行时报错
当我调试时,把cmd那项不加任何where条件时,也是同样的错误各位帮手呀,,,分不够另开贴加NND,折腾死了。。
//这部分就通过了
OleDbConnection con=new OleDbConnection("Provider=Microsoft.Jet.OleDb.4.0;Data Source="+Server.MapPath("/wunjuonline/database/wunjuDB.mdb"));
con.Open();
OleDbCommand cmd=new OleDbCommand("select * from productTable where productID='"+pID+"'",con);
OleDbDataReader odr=cmd.ExecuteReader();
odr.Read();//这部分就是见鬼的代码,不通过。
OleDbConnection con=new OleDbConnection("Provider=Microsoft.Jet.OleDb.4.0;Data Source="+Server.MapPath("/wunjuonline/database/wunjuDB.mdb"));
con.Open();
OleDbCommand cmd=new OleDbCommand("select * from productTable where proudctID='"+pID+"'",con);
OleDbDataReader odr=cmd.ExecuteReader();//这一句错,错误提示如题
odr.Read();两部分完全一样嘛,,怪事。瞅瞅,大家分享一下。