Private Sub CmdDel_Click()
comb_code.Enabled = True
comb_name.Enabled = True
Set myconn = New ADODB.Connection
Set rsinfo = New ADODB.Recordsetmyconn.Open connstring
rsinfo.Open "select *from 员工档案 where 员工编号='" & comb_code.Text & "' ", myconn, adOpenKeyset, adLockOptimistic, adCmdText msg = MsgBox("确定要删除吗?", vbOKCancel, "注意")
 If msg = 1 Then
    If rsinfo.RecordCount <> 0 Then
       'rsinfo.Open "select * from 员工档案 where 员工编号='" & comb_code.Text & "' "
        rsinfo.Delete
        'Adodc1.refresh
        Call nextrecord
        'Adodc1.refresh
        Else
        Call qingkong(清空记录)
        MsgBox "当前没有任何记录", , "移动记录"
    End If
    
        
End If
rsinfo.Close
myconn.Close
End Sub
Private Sub nextrecord()If rsinfo.RecordCount <> 0 Then
       rsinfo.MoveNext
       If rsinfo.EOF Then
        rsinfo.MoveFirst
        End If
   Call duqu
Else
    MsgBox "当前没有任何记录", , "移动记录"
End IfEnd Sub
相关绑定
Private Sub comb_code_Click(Area As Integer)Set myconn = New ADODB.Connection
Set rsinfo = New ADODB.Recordsetmyconn.Open connstringrsinfo.Open "select *from 员工档案 where 员工编号='" & comb_code.Text & "' ", myconn, adOpenKeyset, adLockOptimistic, adCmdText
    comb_name.refresh
    comb_name.Text = rsinfo("员工姓名").Value
    Call duqu
    rsinfo.Close
    myconn.Close
End Sub'上下过程为绑定员工姓名与编号
Private Sub comb_name_Click(Area As Integer)Set myconn = New ADODB.Connection
Set rsinfo = New ADODB.Recordset
 myconn.Open connstring
 rsinfo.Open "select *from 员工档案 where 员工姓名='" & comb_name.Text & "' ", myconn, adOpenKeyset, adLockOptimistic, adCmdText
  comb_code.refresh
  comb_code.Text = rsinfo("员工编号").Value
  Call duqu
  rsinfo.Close
  myconn.CloseEnd Sub

解决方案 »

  1.   

    你的代码用4个字形容"一塌糊涂我的语句很重, Sorry,因为你的代码写得实在...1,rs,Connection只要用Public宣告一次就OK
    2,rs,Connection 在最后再关闭就OK
    3,删除的代码根本没见删除的SQL语句。只有查询
    4,代码最重要是你的逻辑胡乱一片。
    5,数据库用了中文名字和中文字段算了,楼主好好看下书,基础要牢固啊
      

  2.   


    rsinfo.Delete 后应该:rsinfo.Update