我做的一个修改
本来就这样输入来修改数据库中的记录是好好的
SqlConnection conn=new SqlConnection(ConfigurationSettings.AppSettings["dsn"]);
string sql="update guestbook set speak='"+this.edspeak.Text+"',topic='"+this.edtopic.Text+"' where id=" +Request.QueryString["id"];
conn.Open();
SqlCommand comm=new SqlCommand(sql,conn);
comm.ExecuteNonQuery();
conn.Close();
Response.Redirect("index.aspx");
但是当我把数据库中的值用如下语句提取到textbox
string strSql="select topic,speak from guestbook where id=" +Request.QueryString["id"];
conn.Open();
SqlCommand mycommand=new SqlCommand(strSql,conn);
SqlDataReader myReader=mycommand.ExecuteReader();
if(myReader.Read())
{
this.edtopic.Text=myReader.GetValue(0).ToString();
this.edspeak.Text=myReader.GetValue(1).ToString(); }
conn.Close();
myReader.Close(); mycommand.Dispose();
然后再对这些值进行编辑,后提交则修改后还数据库值是一点都没有变!
我的前端页面很简单,就是两个textbox控件
大家说说这是什么原因啊????
急啊!
本来就这样输入来修改数据库中的记录是好好的
SqlConnection conn=new SqlConnection(ConfigurationSettings.AppSettings["dsn"]);
string sql="update guestbook set speak='"+this.edspeak.Text+"',topic='"+this.edtopic.Text+"' where id=" +Request.QueryString["id"];
conn.Open();
SqlCommand comm=new SqlCommand(sql,conn);
comm.ExecuteNonQuery();
conn.Close();
Response.Redirect("index.aspx");
但是当我把数据库中的值用如下语句提取到textbox
string strSql="select topic,speak from guestbook where id=" +Request.QueryString["id"];
conn.Open();
SqlCommand mycommand=new SqlCommand(strSql,conn);
SqlDataReader myReader=mycommand.ExecuteReader();
if(myReader.Read())
{
this.edtopic.Text=myReader.GetValue(0).ToString();
this.edspeak.Text=myReader.GetValue(1).ToString(); }
conn.Close();
myReader.Close(); mycommand.Dispose();
然后再对这些值进行编辑,后提交则修改后还数据库值是一点都没有变!
我的前端页面很简单,就是两个textbox控件
大家说说这是什么原因啊????
急啊!
解决方案 »
- vs2008 combobox 设置value
- 算法问题????
- InstrumentaionManager在运行时可否多次publish有同一个名字的类对象?
- WEB SERVER 配置ISS连接到ORALCE
- ========= 如何实现 aaa[参数] 传入并接收参数?==========
- string[][0] filespilt = Split(postedfile.FileName, "\\"); 错在哪
- 关于.net Remoting的问题?为什么同一个关于客户端订阅服务端事件(服务端广播)的程序,在某些机器上好用,在某些机器上不好用呢?请帮
- 【求教】C#怎么通过URL传递图片?
- 怎么在软件上添加上视频啊
- 如何对依此输入的4个数字进行比较(使用Console.ReadLine),求出最大直和最小值
- 如何DataGrid中使用按扭来实现”删除“和”修改“功能?谁帮我?在线等!谢谢各位前辈!
- 有关C#表达的一个小问题
select 怎么会改变---()
前面确实updata
string strSql="select topic,speak from guestbook where id=" +Request.QueryString["id"];
conn.Open();
SqlCommand mycommand=new SqlCommand(strSql,conn);
SqlDataReader myReader=mycommand.ExecuteReader();
if(myReader.Read())
{
this.edtopic.Text=myReader.GetValue(0).ToString();
this.edspeak.Text=myReader.GetValue(1).ToString(); }
conn.Close();
myReader.Close(); mycommand.Dispose();
//后******************************************************
SqlConnection conn=new SqlConnection(ConfigurationSettings.AppSettings["dsn"]);
string sql="update guestbook set speak='"+this.edspeak.Text+"',topic='"+this.edtopic.Text+"' where id=" +Request.QueryString["id"];
conn.Open();
SqlCommand comm=new SqlCommand(sql,conn);
comm.ExecuteNonQuery();
conn.Close();
Response.Redirect("index.aspx");