代码如下 If Tbookno.Text = "" Then
MsgBox "图书编号不能为空", vbCritical
Exit Sub
End If
If TbookISBN.Text = "" Or _
TbookIndexNO.Text = "" Or _
Tbookname.Text = "" Or _
TbookOrigName.Text = "" Or _
TbookOrigAuthor.Text = "" Or _
TbookTranslater.Text = "" Or _
Tbookpress.Text = "" Or _
Cbooktype.Text = "" Or _
Tbooklanguage.Text = "" Or _
Tbookpages.Text = "" Or _
Tbookprice.Text = "" Or _
Tbookother.Text = "" Or _
DTbookpubdate.Value = "" Or _
DTbookenrolDate.Value = "" Then
MsgBox "对不起,数据输入不合法,除图书信息备注可为空外,其他不能为空!", vbCritical
Exit Sub
End If
Sqlstr = "select * from books"
Inform_Rec.Open DBcnn, Sqlstr, adOpenStatic, adLockOptimistic 这里出错了
If Inform_Rec.RecordCount <> 0 Then
Inform_Rec.AddNew '更新
with Inform_Rec
.Fields("bookname") = Replace(Trim(Tbookname.Text), "'", "''")
.Fields("bookno").Value = Trim(Tbookno.Text) '在这里文本都为空
.Fields("bookISBN").Value = Trim(TbookISBN.Text)
.Fields("bookIndexNO").Value = Trim(TbookIndexNO.Text)
.Fields("bookname").Value = Trim(Tbookname.Text)
.Fields("bookOrigName").Value = Trim(TbookOrigName.Text)
.Fields("bookOrigAuthor").Value = Trim(TbookOrigAuthor.Text)
.Fields("bookTranslate").Value = Trim(TbookTranslater.Text)
.Fields("booktype").Value = Trim(Cbooktype.Text)
.Fields("booklanguage").Value = Trim(Tbooklanguage.Text)
.Fields("bookpages").Value = Trim(Tbookpages.Text)
.Fields("bookprice").Value = Trim(Tbookprice.Text)
.Fields("bookother").Value = Trim(Tbookother.Text)
.Fields("bookpubdate").Value = DTbookpubdate.Value
.Fields("bookenrolDate").Value = DTbookenrolDate.Value
.Update
MsgBox "数据添加成功!!", vbInformation
Inform_Rec.Refresh
End With
Else
MsgBox "记录不存在!", vbInformation
Exit Sub
End If
MsgBox "图书编号不能为空", vbCritical
Exit Sub
End If
If TbookISBN.Text = "" Or _
TbookIndexNO.Text = "" Or _
Tbookname.Text = "" Or _
TbookOrigName.Text = "" Or _
TbookOrigAuthor.Text = "" Or _
TbookTranslater.Text = "" Or _
Tbookpress.Text = "" Or _
Cbooktype.Text = "" Or _
Tbooklanguage.Text = "" Or _
Tbookpages.Text = "" Or _
Tbookprice.Text = "" Or _
Tbookother.Text = "" Or _
DTbookpubdate.Value = "" Or _
DTbookenrolDate.Value = "" Then
MsgBox "对不起,数据输入不合法,除图书信息备注可为空外,其他不能为空!", vbCritical
Exit Sub
End If
Sqlstr = "select * from books"
Inform_Rec.Open DBcnn, Sqlstr, adOpenStatic, adLockOptimistic 这里出错了
If Inform_Rec.RecordCount <> 0 Then
Inform_Rec.AddNew '更新
with Inform_Rec
.Fields("bookname") = Replace(Trim(Tbookname.Text), "'", "''")
.Fields("bookno").Value = Trim(Tbookno.Text) '在这里文本都为空
.Fields("bookISBN").Value = Trim(TbookISBN.Text)
.Fields("bookIndexNO").Value = Trim(TbookIndexNO.Text)
.Fields("bookname").Value = Trim(Tbookname.Text)
.Fields("bookOrigName").Value = Trim(TbookOrigName.Text)
.Fields("bookOrigAuthor").Value = Trim(TbookOrigAuthor.Text)
.Fields("bookTranslate").Value = Trim(TbookTranslater.Text)
.Fields("booktype").Value = Trim(Cbooktype.Text)
.Fields("booklanguage").Value = Trim(Tbooklanguage.Text)
.Fields("bookpages").Value = Trim(Tbookpages.Text)
.Fields("bookprice").Value = Trim(Tbookprice.Text)
.Fields("bookother").Value = Trim(Tbookother.Text)
.Fields("bookpubdate").Value = DTbookpubdate.Value
.Fields("bookenrolDate").Value = DTbookenrolDate.Value
.Update
MsgBox "数据添加成功!!", vbInformation
Inform_Rec.Refresh
End With
Else
MsgBox "记录不存在!", vbInformation
Exit Sub
End If
我在之前定义,而且在运行时,通过添加监视,它都有显示信息的!
Public DBcnn As New ADODB.Connection我搞了很久都没有完成,真是郁闷吗!那位高手可以指点,指点!!多谢!
当我运行到这一步时,说会出现错误,为什么呢!
是不是adOpenStatic, adLockOptimistic有问题?
但我改用其他的,都会出现这样的情况?
??
谁可以说做一个专题,有关于为什么用adcmdtext,AdCmdTable...有时不用也行!