标题:请高手帮忙! 关于在VB里修改ACCESS数据库数据
取消只看楼主
xubowei
Rank: 1
等 级:新手上路
帖 子:2
专家分:0
注 册:2008-11-25
 问题点数:0 回复次数:0 
请高手帮忙! 关于在VB里修改ACCESS数据库数据
我在VB修改界面上想实现(公司名称不能为空和不能重复)  但是我利用下面代码没能实现 而是无论输入什么信息都提示公司名称已经存在并且保存了!  请高手们帮帮我!!!   
数据库第一项是供应商编号 第二项是公司名称

Private Sub Command4_Click()
  On Error Resume Next
   If Text2.Text = "" Then
     MsgBox "公司名称不能为空", 0 + 48, "提示"
         Adodc1.ConnectionString = "Provider=Microsoft.Jet.OLEDB.4.0;Data Source=" + App.Path + "\贸易公司.mdb;Persist Security Info=False;Jet OLEDB:Database Password=fzy"
         Adodc1.RecordSource = "供应商信息表"
         Adodc1.Refresh
               Text1 = Adodc1.Recordset.Fields(0)
               Text2 = Adodc1.Recordset.Fields(1)
              Text2.SetFocus
        Else
                             Adodc1.Recordset.Find "公司名称='" + Text2.Text + "'"
                             If Not Adodc1.Recordset.EOF Then
                               Dim aa As String
                               aa = Adodc1.Recordset.Fields(1)
                                   End If
                                       If aa = Text2.Text Then
         
                                           MsgBox "公司名称已经存在,请重新输入!", 0 + 48, "提示"
                                       Adodc1.Recordset.CancelUpdate
                                           Adodc1.Refresh
                                      Else
                                             Text2 = Adodc1.Recordset.Fields(1)
                                                 Adodc1.Recordset.Update
                                                  MsgBox "保存成功", 0 + 48, "提示"
                                      
                                          
                                                 End If
                                              End If
End Sub
搜索更多相关主题的帖子: 数据库 ACCESS 
2010-02-23 22:22



参与讨论请移步原网站贴子:https://bbs.bccn.net/thread-298002-1-1.html




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

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