修改数据库Name字段,首先我在修改页的Page_Load加载事件里先查询出来,代码如下:
SqlCommand cmd = new SqlCommand(select * from Table, conn);
SqlDataAdapter sda = new SqlDataAdapter(cmd);
DataSet ds = new DataSet();
sda.Fill(ds);
this.txtMingcheng.Text = ds.Tables[0].Rows[0]["Name"].ToString();//查询结果例如是:123,然后放到文本框里了。
我现在要把我查询出来的结果修改,代码如下:
string sqlstr = "update Table set Name="+this.txtMingcheng.Text+";
SqlCommand cmd = new SqlCommand(sqlstr,conn);
SqlDataAdapter sda = new SqlDataAdapter(cmd);
DataSet ds = new DataSet();
sda.Fill(ds);问题出来了,当我在文本框里输入456的时候点提交,然后数据还是123?这咋办啊?
SqlCommand cmd = new SqlCommand(select * from Table, conn);
SqlDataAdapter sda = new SqlDataAdapter(cmd);
DataSet ds = new DataSet();
sda.Fill(ds);
this.txtMingcheng.Text = ds.Tables[0].Rows[0]["Name"].ToString();//查询结果例如是:123,然后放到文本框里了。
我现在要把我查询出来的结果修改,代码如下:
string sqlstr = "update Table set Name="+this.txtMingcheng.Text+";
SqlCommand cmd = new SqlCommand(sqlstr,conn);
SqlDataAdapter sda = new SqlDataAdapter(cmd);
DataSet ds = new DataSet();
sda.Fill(ds);问题出来了,当我在文本框里输入456的时候点提交,然后数据还是123?这咋办啊?
解决方案 »
- 打印报Only one ScriptX object can be used per browser window
- 求C# 高性能的图像锐化算法。flickr的锐化效果非常好啊。。。
- 在Dictionary<int,string>泛型集合中,如何通过值来获得相应的键呢?
- 高分求教:如何使一个DataTable的Columns成为另外一个table的具体内容
- 分不多,大家别嫌弃,过来看看
- ReadFile 读取 自己的驱动的数据 出错 ??
- 关于C#的事件!
- .net环境配置?出现从池中获取连接之前超时时间已到。高手帮忙。在线等待
- C#操作word的问题?
- 类的继承次数过多会不会造成速度的减慢?
- vs2008 打包安装
- WebBroswer与 Winform 简单交互问题
{
SqlCommand cmd = new SqlCommand(select * from Table, conn);
SqlDataAdapter sda = new SqlDataAdapter(cmd);
DataSet ds = new DataSet();
sda.Fill(ds);
this.txtMingcheng.Text = ds.Tables[0].Rows[0]["Name"].ToString();//查询结果例如是:123,然后放到文本框里了。
}