有请各位高手帮我看看。为什么…在添加新的信息按“保存”按钮时出现“FROM子语句错误”和“实时错误-2147217900(800400e14)对象Refresh的方法IAdodc失败”和上面提示 ,并且序号一列无法生成连贯序号红圈处,为什么。  毫无头绪,望前辈们不啬赐教说说原因。。先谢谢啦!!!!!
部分代码如下: 
Private Sub cmdAdd_Click()
  isAdd = True
  SaveCancelEnabled
  AdodcReaderType.Recordset.AddNew
  TextEnabledTrue
  txtReaderTypeNo(0).SetFocus
End SubPrivate Sub cmdCancel_Click()
  If AdodcReaderType.Recordset.RecordCount > 0 Then
       AdodcReaderType.Recordset.CancelUpdata
  End If
  initialCmd
  TextEnabledFalse
  DataGridReaderType.Refresh
  AdodcReaderType.Refresh
End SubPrivate Sub cmdClose_Click()
  End
  Unload Me
End SubPrivate Sub cmdDelete_Click()
  If MsgBox("真的要删除类别名称为:【" & Trim(txtReaderTypeName.Text) & "】的类别吗? ", vbYesNo, "提示信息") = vbYes Then
     AdodcReaderType.Recordset.Delete
     AdodcReaderType.Recordset.MoveNext
     If AdodcReaderType.Recordset.EOF Then
         AdodcReaderType.Recordset.MovePrevious
        If AdodcReaderType.Recordset.BOF Then
           MsgBox "读者类别表中的数据已被清空", , "提示信息"
  Exit Sub
        End If
      End If
    End If
     DataGridReaderType.Refresh
End SubPrivate Sub cmdEdit_Click()
  isEdit = True
  SaveCancelEnabled
  TextEnabledTrue
  txtReaderTypeNo(0).SetFocus
End SubPrivate Sub cmdSave_Click()
  initialCmd
  If Trim(txtReaderTypeNo(0).Text) = "" Or Trim(txtReaderTypeName(1).Text) = "" _
     Or Trim(txtLoanNumber(2).Text) = "" Or Trim(txtBorrowTerm(3).Text) = "" _
     Or Trim(txtForfeitDay(4).Text) = "" Then
     MsgBox "请将读者类别数据填写完整! ", , "提示信息"
     cmdSave.Enabled = True
     cmdCancel.Enabled = True
     txtReaderTypeNo(0).SetFocus
  End If
    
  AdodcTemp.RecordSource = "select * form ReaderType where ReaderTypeNo(0)=" _
  & " ' " & Trim(txtReaderTypeNo(0).Text) & " '"
     AdodcTemp.Refresh“程序调试时黄色条就定位到这行,鼠标移到上面右键定义显示:不能跳转到AdodcTEMP,由于它被隐藏。或是:不能跳转到AdodcTEMP,由于在库中Unknown7该库当前未被引用。这应该怎么做
     RecCount = AdodcTemp.Recordset.RecordCount
  If isAdd Then
     If RecCount > 0 Then
        MsgBox "此类别编号已经存在,请重新输入! ", , "提示信息"
        txtReaderTypeNo(0).SetFocus
        txtReaderTypeNo(0).SelStart = 0
        txtReaderTypeNo(0).SelLength = Len(txtReaderTypeNo(0).Text)
        cmdSave.Enabled = True
        cmdCancel.Enabled = True
        Exit Sub
  Else
    AdodcReaderType.Recordset.Update
      MsgBox "已成功添加新的读者类别!", , "提示信息"
      AdodcReaderType.Recordset.MoveLast
      TextEnabledFalse
    End If
  ElseIf isEdit Then
    If RecCount > 1 Then
      MsgBox "此类别编号已经存在,请重新输入! ", , "提示信息"
      txtReaderTypeNo(0).SetFocus
      txtReaderTypeNo(0).SelStart = 0
      txtReaderTypeNo(0).SelLength = Len(txtReaderTypeNo(0).Text)
      cmdSave.Enabled = True
      cmdCancel.Enabled = True
      Exit Sub
  Else
    AdodcReaderType.Recordset.Update
      MsgBox "已成功添加新的读者类别!", , "提示信息"
         isAdd = False
         AdodcReaderType.Recordset.MoveLast
         TextEnabledFalse
    End If
  ElseIf isEdit Then
    If RecCount > 1 Then
      MsgBox "此类别编号已经存在,请重新输入! ", , "提示信息"
      txtReaderTypeNo(0).SetFocus
      txtReaderTypeNo(0).SelStart = 0
      txtReaderTypeNo(0).SelLength = Len(txtReaderTypeNo(0).Text)
      cmdSave.Enabled = True
      cmdCancel.Enabled = True
      Exit Sub
  Else
      AdodcReaderType.Recordset.Update
      MsgBox "所修改的读者类别数据已保存! ", , "提示信息"
      isEdit = False
      AdodcReaderType.Refresh
      TextEnabledFalse
    End If
  End If
    DataGridReaderType.Refresh
  
End Sub

解决方案 »

  1.   

    要保证ReaderTypeNo(0)的数据类型是字符串才可以
      

  2.   

    帮楼主重新写下:
    Private Sub cmdAdd_Click() 
      isAdd = True 
      SaveCancelEnabled 
      AdodcReaderType.Recordset.AddNew 
      TextEnabledTrue 
      txtReaderTypeNo(0).SetFocus 
    End Sub Private Sub cmdCancel_Click() 
      If AdodcReaderType.Recordset.RecordCount > 0 Then 
          AdodcReaderType.Recordset.CancelUpdata 
      End If 
      initialCmd 
      TextEnabledFalse 
      DataGridReaderType.Refresh 
      AdodcReaderType.Refresh 
    End Sub Private Sub cmdClose_Click() 
      End 
      Unload Me 
    End Sub Private Sub cmdDelete_Click() 
      If MsgBox("真的要删除类别名称为:【" & Trim(txtReaderTypeName.Text) & "】的类别吗? ", vbYesNo, "提示信息") = vbYes Then 
        AdodcReaderType.Recordset.Delete 
        AdodcReaderType.Recordset.MoveNext 
        If AdodcReaderType.Recordset.EOF Then 
            AdodcReaderType.Recordset.MovePrevious 
            If AdodcReaderType.Recordset.BOF Then 
              MsgBox "读者类别表中的数据已被清空", , "提示信息" 
      Exit Sub 
            End If 
          End If 
        End If 
        DataGridReaderType.Refresh 
    End Sub Private Sub cmdEdit_Click() 
      isEdit = True 
      SaveCancelEnabled 
      TextEnabledTrue 
      txtReaderTypeNo(0).SetFocus 
    End Sub Private Sub cmdSave_Click() 
      initialCmd 
      If Trim(txtReaderTypeNo(0).Text) = "" Or Trim(txtReaderTypeName(1).Text) = "" _ 
        Or Trim(txtLoanNumber(2).Text) = "" Or Trim(txtBorrowTerm(3).Text) = "" _ 
        Or Trim(txtForfeitDay(4).Text) = "" Then 
        MsgBox "请将读者类别数据填写完整! ", , "提示信息" 
        cmdSave.Enabled = True 
        cmdCancel.Enabled = True 
        txtReaderTypeNo(0).SetFocus 
      End If 
        
      AdodcTemp.RecordSource = "select * form ReaderType where ReaderTypeNo(0)=" _ 
      & " ' " & Trim(txtReaderTypeNo(0).Text) & " '" 
        AdodcTemp.Refresh“程序调试时黄色条就定位到这行,鼠标移到上面右键定义显示:不能跳转到AdodcTEMP,由于它被隐藏。或是:不能跳转到AdodcTEMP,由于在库中Unknown7该库当前未被引用。这应该怎么做 
        RecCount = AdodcTemp.Recordset.RecordCount 
      If isAdd Then 
        If RecCount > 0 Then 
            MsgBox "此类别编号已经存在,请重新输入! ", , "提示信息" 
            txtReaderTypeNo(0).SetFocus 
            txtReaderTypeNo(0).SelStart = 0 
            txtReaderTypeNo(0).SelLength = Len(txtReaderTypeNo(0).Text) 
            cmdSave.Enabled = True 
            cmdCancel.Enabled = True 
            Exit Sub 
      Else 
        AdodcReaderType.Recordset.Update 
          MsgBox "已成功添加新的读者类别!", , "提示信息" 
          AdodcReaderType.Recordset.MoveLast 
          TextEnabledFalse 
        End If 
      ElseIf isEdit Then 
        If RecCount > 1 Then 
          MsgBox "此类别编号已经存在,请重新输入! ", , "提示信息" 
          txtReaderTypeNo(0).SetFocus 
          txtReaderTypeNo(0).SelStart = 0 
          txtReaderTypeNo(0).SelLength = Len(txtReaderTypeNo(0).Text) 
          cmdSave.Enabled = True 
          cmdCancel.Enabled = True 
          Exit Sub 
      Else 
        AdodcReaderType.Recordset.Update 
          MsgBox "已成功添加新的读者类别!", , "提示信息" 
            isAdd = False 
            AdodcReaderType.Recordset.MoveLast 
            TextEnabledFalse 
        End If 
      ElseIf isEdit Then 
        If RecCount > 1 Then 
          MsgBox "此类别编号已经存在,请重新输入! ", , "提示信息" 
          txtReaderTypeNo(0).SetFocus 
          txtReaderTypeNo(0).SelStart = 0 
          txtReaderTypeNo(0).SelLength = Len(txtReaderTypeNo(0).Text) 
          cmdSave.Enabled = True 
          cmdCancel.Enabled = True 
          Exit Sub 
      Else 
          AdodcReaderType.Recordset.Update 
          MsgBox "所修改的读者类别数据已保存! ", , "提示信息" 
          isEdit = False 
          AdodcReaderType.Refresh 
          TextEnabledFalse 
        End If 
      End If 
        DataGridReaderType.Refresh 
      
    End Sub 
      

  3.   

    在cmdSave_Click中加上错误捕获,定位一下具体出错的语句。
      

  4.   

    ReaderType 表中有字段 ReaderTypeNo(0) ???
    AdodcTemp.ConnectionString 设置了吗
      

  5.   

    AdodcTemp.RecordSource = "select * form ReaderType where ReaderTypeNo(0)=" _ 
      & " ' " & Trim(txtReaderTypeNo(0).Text) & " '" 写错了,应该是from这个从错误信息“FROM子语句错误”中就能基本确定是sql语句上的问题
      

  6.   

    AdodcTemp.RecordSource = "select * from ReaderType where ReaderTypeNo(0)=" _ 
      & " ' " & Trim(txtReaderTypeNo(0).Text) & " '"