CSDN首页 空间 新闻 论坛 Blog 下载 读书 网摘 搜索 .NET Java 视频 接项目 求职 在线学习 买书 程序员 通知
IBM Rational 系统开发最佳实践工具包 WebSphere MQ 最佳实践 TOP 15
CSDN社区
搜索 收藏 打印 关闭
CSDN社区 >  VB >  数据库(包含打印,安装,报表)

求救~~Delete语句错误...

楼主Kenlist_world(⊙热血少年⊙)2006-03-18 20:56:31 在 VB / 数据库(包含打印,安装,报表) 提问

Dim   Cn   As   New   ADODB.Connection  
  Dim   Rs   As   New   ADODB.Recordset  
   
  Private   Sub   Form_Load()  
  Show  
  Set   Cn   =   New   ADODB.Connection  
  Cn.ConnectionString   =   "Provider=Microsoft.Jet.OLEDB.4.0;Data   Source="   &   App.Path   &   "\data.mdb;Persist   Security   info   =   False"  
  Cn.Open  
  Adodc1.ConnectionString   =   Cn  
  Adodc1.RecordSource   =   "select   *   from   用户"  
  Adodc1.Refresh  
  Set   Text1.DataSource   =   Adodc1  
  Text1.DataField   =   "username"  
  End   Sub  
   
  Private   Sub   Command1_Click()  
  Adodc1.RecordSource   =   "delete   from   用户   where   username   =   '"   &   Text1.Text   &   "'"  
  Adodc1.Refresh  
  DataGrid1.Refresh  
  End   Sub  
   
   
  弹出错误对话框:(Adodc1)"对象关闭时,不允许操作"  
  调试时为Adodc1.Refresh发生错误  
  如果没有它,删除语句又没响应..该怎么做..  
   
  问题点数:30、回复次数:8Top

1 楼faysky2(出来混,迟早是要还嘀)回复于 2006-03-18 21:16:47 得分 0

用ADO来做删除,不要用Adodc  
   
  Top

2 楼Kenlist_world(⊙热血少年⊙)回复于 2006-03-18 21:26:15 得分 0

什么意思??Top

3 楼fxj331072(白天与黑夜)回复于 2006-03-18 21:32:48 得分 10

Private   Sub   Command1_Click()  
  Adodc1.RecordSource   =   "select   *   from   用户   where   username   =   '"   &   Text1.Text   &   "'"  
  Adodc1.Refresh  
  if   Adodc1.Recordset.eof=false   then  
      Adodc1.Recordset.Delete  
      Adodc1.Recordset.Update  
  end   if  
  DataGrid1.Refresh  
  End   Sub  
  Top

4 楼aektnick(雨)回复于 2006-03-18 21:36:07 得分 0

 
  Private   Sub   Command1_Click()  
  Adodc1.RecordSource   =   "delete   from   用户   where   username   =   '"   &   Text1.Text   &   "'"  
  Adodc1.Refresh  
  DataGrid1.Refresh  
  End   Sub  
  ---------------------------------------  
  private   sub   Command1_click  
  Adodc1.RecordSource   =   "select   from   用户   where   username   =   '"   &   Text1.Text   &   "'"  
  Adodc1.Refresh  
    if   adodc1.recordset.eof=false   then  
              adodc1.recodset.delect  
              adodc1.refresh  
    end   if  
  DataGrid1.Refresh  
  end   sub  
   
  ----------------------------  
  用ADO   来删除简单很多Top

5 楼Kenlist_world(⊙热血少年⊙)回复于 2006-03-18 22:01:55 得分 0

非常感谢吖!可是我很想知道  
  If   Adodc1.Recordset.EOF   =   False   Then  
      Adodc1.Recordset.Delete  
      Adodc1.Recordset.Update  
  End   If  
  为何加了这段代码就可以了?它有什么作用吖?能否解释一下给小弟听呢?  
  另外什么叫用ADO来删除?怎么删除法?Top

6 楼faysky2(出来混,迟早是要还嘀)回复于 2006-03-18 22:58:37 得分 10

什么叫用ADO来删除?  
  ---------------------  
  Cn.Execute("delete   from   用户   where   username   =   '"   &   Text1.Text   &   "'")    
  Top

7 楼fxj331072(白天与黑夜)回复于 2006-03-19 01:03:27 得分 5

If   Adodc1.Recordset.EOF   =   False   Then  
      Adodc1.Recordset.Delete  
      Adodc1.Recordset.Update  
  End   If  
   
  意思是如果找到记录就删除它!Top

8 楼icbcnbxs(我来灌水)回复于 2006-03-19 11:59:39 得分 5

既然定义了CONN,如果只是删除,何必在用adodc什么的呢,直接用  
  Cn.execute   "delete   *   from   用户   where   username   =   '"   &   Text1.Text   &   "'"  
   
  不就OK了??Top

相关问题

  • INSERT INTO 语句错误?
  • SQL语句错误
  • sql语句错误!
  • sql 语句错误!
  • 关于ADOQuery中使用Delete语句执行错误的问题
  • 求Delete语句
  • sql语句错误~~问题
  • SQL语句提示错误。
  • sql 语句出现错误!
  • 检测语句错误

关键词

  • 用户
  • adodc
  • recordsource
  • refreshend
  • 错误
  • 删除
  • delete
  • sub
  • 用户where username
  • recordset

得分解答快速导航

  • 帖主:Kenlist_world
  • fxj331072
  • faysky2
  • fxj331072
  • icbcnbxs

相关链接

  • Visual Basic类图书
  • Visual Basic类源码下载

广告也精彩

反馈

请通过下述方式给我们反馈
反馈
提问
网站简介|广告服务|VIP资费标准|银行汇款帐号|网站地图|帮助|联系方式|诚聘英才|English|问题报告
北京创新乐知广告有限公司 版权所有, 京 ICP 证 070598 号
世纪乐知(北京)网络技术有限公司 提供技术支持
Copyright © 2000-2008, CSDN.NET, All Rights Reserved
GongshangLogo