//string cmd_insert_str = "update connect_info set class_id=@class_id,child_id=@child_id,connect_title=@connect_title,connect_connect=@connect_connect,addition_id=@addition_id,connect_time=@connect_time where connect_id=@connect_id";
string cmd_update_str = "update connect_info set class_id="+this.parent_class_name.SelectedValue+",child_id=" + this.class_name.SelectedValue + ",connect_title='" + this.title_name.Text + "',connect_connect='" + this.FCKeditor1.Value.ToString() + "',addition_id='" + strFileDownloadPath + "',connect_time='" + DateTime.Now.ToString() + "' where connect_id=@connect_id";
using (OleDbConnection my_conn = new OleDbConnection(myconnectionstring))
{
my_conn.Open();
using (OleDbCommand my_cmd = new OleDbCommand(cmd_update_str, my_conn))
{
my_cmd.Parameters.AddWithValue("@connect_id", Convert.ToInt32(Request.QueryString["id"].ToString()));
//my_cmd.Parameters.AddWithValue("@class_id", Convert.ToInt32(this.parent_class_name.SelectedValue));
//my_cmd.Parameters.AddWithValue("@child_id", this.class_name.SelectedValue == null ? 200 : Convert.ToInt32(this.class_name.SelectedValue));
//my_cmd.Parameters.AddWithValue("@connect_title", this.title_name.Text);
//my_cmd.Parameters.AddWithValue("@connect_connect", this.FCKeditor1.Value.ToString());
//my_cmd.Parameters.AddWithValue("@addition_id", strFileDownloadPath);
//my_cmd.Parameters.AddWithValue("@connect_time", DateTime.Now.ToString());
my_cmd.ExecuteNonQuery();
}
}
Response.Write(this.parent_class_name.SelectedValue);
Response.Write(this.class_name.SelectedValue);
//Response.Write(cmd_update_str);
this.title_name.Text = "";
this.FCKeditor1.Value = "";代码如上:我如果采用参数化传值,就无法实现更新操作,也不提示报错。采用直接在sql语句赋值就能实现更新操作。请问是哪里不对呀?页面上的取值都是有的。
解决方案 »
- vs2008 使用jQuery
- 求助:NullReferenceException: 未将对象引用设置到对象的实例
- (100分啊)数据库恢复出现错误,,未将对象引用设置到对象的实例
- 告诉我Asp.net2.0与1.x下这个为什么不一样了?
- 新手问题:我的这段代码有什么问题呀,为什么总是出错?
- DataGrid 显示问题
- datagrid的新增问题
- treeview控件,我已经加到工具栏里面去了。可是我在代码里面直接定义new 的时候,自动显示中没有,编译的时候也出错,这个怎么回事呀,急
- 求仿58仿赶集多图片上传控件并支持排序【asp.net版】
- 特别郁闷的问题,在我的机子上没有问题,但是到了客户哪里中文图片就不显示了
- 求datalist详细用法,包含一切的用法,多谢。
- ASP.Net怎样连接MySQL
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.Web.UI.HtmlControls;
using System.Data.OleDb;
using System.IO;这是头部引用
SELECT * FROM Customers WHERE CustomerID = ?
并且添加到 Parameters 集合中的参数顺序必须与 Command 中参数的顺序相匹配。
是的。楼主的第一个 AddWithValue("@connect_id", 位置就不对,应该放在最后。而且,就算写了@名字,也根本不认!