CSDN首页 空间 新闻 论坛 Blog 下载 读书 网摘 搜索 .NET Java 视频 接项目 求职 在线学习 买书 程序员 通知
可用分押宝游戏火热进行中... 专题改版:Java Web 专题
CSDN社区
搜索 收藏 打印 关闭
CSDN社区 >  .NET技术 >  VB.NET

请高手指教

楼主cityhunter911()2003-11-01 17:49:04 在 .NET技术 / VB.NET 提问

我想删除数据表中的一条记录,可为什么她说我“标准表达式中数据类型不匹配”和“至少一个参数没有被指定值”  
  以下是我的删除代码:  
   
          Private   Sub   Button1_Click(ByVal   sender   As   System.Object,   ByVal   e   As   System.EventArgs)   Handles   Button1.Click  
                  'Dim   mainform   As   New   Form3()  
                  If   txtID.ReadOnly()   =   True   And   txtName.ReadOnly()   =   False   Then  
                          If   txtName.Text   =   ""   Then  
                                  MessageBox.Show("你还没有输入姓名!",   "info",   MessageBoxButtons.OK)  
                          Else  
                                  OleDbCommand1.CommandText   =   "delete   from   HousingCard   where   HousingMaster='"   +   txtName.Text   +   "'"  
                                  OleDbConnection1.Open()  
                                  OleDbCommand1.ExecuteNonQuery()  
                                  MessageBox.Show("已经删除成功!",   "info",   MessageBoxButtons.OK)  
                                  Me.Close()  
                          End   If  
                  ElseIf   txtID.ReadOnly()   =   False   And   txtName.ReadOnly()   =   True   Then  
                          If   txtID.Text   =   ""   Then  
                                  MessageBox.Show("你还没有输入ID!",   "info",   MessageBoxButtons.OK)  
                          Else  
                                  OleDbCommand1.CommandText   =   "delete   from   HousingCard   where   HousingCardID='"   +   txtID.Text   +   "'"  
                                  OleDbConnection1.Open()  
                                  OleDbCommand1.ExecuteNonQuery()  
                                  MessageBox.Show("已经删除成功!",   "info",   MessageBoxButtons.OK)  
                                  Me.Close()  
                          End   If  
                  End   If  
          End   Sub 问题点数:0、回复次数:2Top

1 楼rock29(rock)回复于 2003-11-08 16:55:30 得分 0

只有这些代码是判断不出来的,建议你在两个else(删除的那个)中使用try..catch..end   try结构看看是哪处有问题.  
  我估计是HousingCardID可能是integer型,而你用了char型Top

2 楼fanyli(李咏)回复于 2003-11-08 17:05:40 得分 0

OleDbCommand1.CommandText   =   "delete   from   HousingCard   where   HousingMaster='"   +   txtName.Text   +   "'"  
  OleDbCommand1.CommandText   =   "delete   from   HousingCard   where   HousingCardID='"   +   txtID.Text   +   "'"  
  以上该为  
  OleDbCommand1.CommandText   =   "delete   from   HousingCard   where   HousingMaster='"   &   txtName.Text   &   "'"  
  OleDbCommand1.CommandText   =   "delete   from   HousingCard   where   HousingCardID='"   &   txtID.Text   &   "'"  
   
  来试一下!  
  Top

相关问题

  • 请
  • 请
  • 请教!请教!
  • 请 请问???
  • 请进!请进?
  • 请进,请进....
  • 请教请教!!!
  • 请教!请教!
  • 请教,请教!!!
  • 请教~~请教!!!

关键词

  • txtname
  • txtid
  • messageboxbuttons
  • 删除
  • readonly
  • oledbcommand
  • messagebox
  • show
  • ok
  • then

得分解答快速导航

  • 帖主:cityhunter911

相关链接

  • CSDN .NET频道
  • .NET类图书
  • C#类图书
  • .NET类源码下载

广告也精彩

反馈

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