有请各位高手帮我看看,做一个“图书管理”。为什么…在添加新的信息按“保存”按钮时出现“FROM子语句错误”和“实时错误-2147217900(800400e14)对象Refresh的方法IAdodc失败”和上面提示 ,但在关闭程序之后数据能写入,并且序号一列无法生成连贯序号像是累计的序号,如果删除几行就出现序号空缺,在按“取消”按钮时出现“未找到方法或数据成员”并指向AdodcReaderType.Recordset.CancelUpdata这一条。AdodcTemp这个出现问题的可能性大吗在按各位大侠指出可能的地方都排查了,可还是一切如旧 毫无头绪,望前辈们不啬赐教说说原因。。先谢谢啦!!!!!
部分代码如下:
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 * from 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
部分代码如下:
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 * from 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
ReaderTypeNo(0)
2、序号自动增加字段,确实是自动累加的,删除后再添加就会不连续,因为删除并不是真的删除,而是标记为删除,起始还是存在的。可以试一下,文件会越来越大。删除也不会变小。
3、我一般都不用自动增加类型。
有这个字段名ReaderTypeNo(0),也能连接数据库数据,在保存之前,就出现错误提示:MICROSOFT DATA GRID 由于将在索引主关键字或关系中创建重复的值,请求对表的改变没有成功,改变该字段的或包含重复数据的字段中数据,删除索引或重新定义索引以允许重复的值再试一次。这段提示的可能错误是什么....ReaderType 表中有字段 ReaderTypeNo(0)
AdodcTemp.ConnectionString 也设置了啊