| 网站首页 | 业界新闻 | 小组 | 威客 | 人才 | 下载频道 | 博客 | 代码贴 | 在线编程 | 编程论坛
欢迎加入我们,一同切磋技术
用户名:   
 
密 码:  
共有 505 人关注过本帖
标题:[求助]DELETE
只看楼主 加入收藏
lujinhui66
Rank: 1
等 级:新手上路
帖 子:8
专家分:0
注 册:2006-5-22
收藏
 问题点数:0 回复次数:1 
[求助]DELETE

string StrSQL="DELETE FROM gqsz WHERE xh='"+this.listView1.SelectedItems [0].Text.Trim()+"'";
this.sqlCommand1.CommandText=StrSQL;
this.sqlCommand1.Connection=this.con;
//打开数据库连接
this.con.Open();
//执行SQL命令
this.sqlCommand1.ExecuteNonQuery();
//关闭连接
this.con.Close();
//更新数据集
this.dataSet1.Tables["gqsz"].Rows[this.MyBind.Position].BeginEdit();
this.dataSet1.Tables["gqsz"].Rows[this.MyBind.Position].EndEdit();
this.dataSet1.AcceptChanges();
this.SqlDataAdapter1.Fill(this.dataSet1,"gqsz");
this.MyBind.Position=this.MyBind.Count;

MessageBox.Show("此操作将会删除选定的歌曲","信息提 示",MessageBoxButtons.YesNo,MessageBoxIcon.Question,MessageBoxDefaultButton.Button1);

错误显示:未将对象引用设置到对象实例。

小弟刚学,很菜
是哪里应该怎么写!!!!万分感谢!!!!!

搜索更多相关主题的帖子: DELETE 
2006-05-24 22:15
keikei
Rank: 2
等 级:新手上路
威 望:4
帖 子:152
专家分:0
注 册:2006-5-15
收藏
得分:0 
调试的时后应该有显示的,那里出错,并且你写的也不详细,恩---估计错出在下面某个位置吧,你与其它的连接数库部分对照一下看看哪里有错??恩---好象每次建立连接都要new Connection之类的,你再看看吧,具体哪里有错?
string StrSQL="DELETE FROM gqsz WHERE xh='"+this.listView1.SelectedItems [0].Text.Trim()+"'";
this.sqlCommand1.CommandText=StrSQL;
this.sqlCommand1.Connection=this.con;
//打开数据库连接
this.con.Open();
//执行SQL命令
this.sqlCommand1.ExecuteNonQuery();
//关闭连接
this.con.Close();
2006-05-25 09:45
快速回复:[求助]DELETE
数据加载中...
 
   



关于我们 | 广告合作 | 编程中国 | 清除Cookies | TOP | 手机版

编程中国 版权所有,并保留所有权利。
Powered by Discuz, Processed in 0.014130 second(s), 7 queries.
Copyright©2004-2024, BCCN.NET, All Rights Reserved