新手上路,各位大虾帮帮忙!
一个信息输入的界面,每次运行的时候Rss总会报错:Set Rss = Cnn.Execute(SQL) 实时错误424,要求对象
如果把检测相同记录的程序删除,运行到Rss.AddNew时仍会报424的错误
各位帮帮忙,帮我解决一下!
Private Sub CmdOK_Click()
Dim txtSQL As String
'信息完整输入
If Trim(Text1.Text) = "" Then
MsgBox "请输入完整!", vbOKOnly + vbExclamation, "提示"
Text1.SetFocus
Exit Sub
End If
If Trim(Text2.Text) = "" Then
MsgBox "请输入完整!", vbOKOnly + vbExclamation, "提示"
Text2.SetFocus
Exit Sub
End If
If Trim(Text3.Text) = "" Then
MsgBox "请输入完整!", vbOKOnly + vbExclamation, "提示"
Text3.SetFocus
Exit Sub
End If
‘检测手册号是否重复
txtSQL = "select * from LX_QYSC where SCH='" & Trim(Text3.Text) & "'"
Set Rss = Cnn.Execute(SQL)
If Rss.BOF = ture Then
MsgBox " 手册号已存在,请检查!", vbOKCancel + vbExclamation, "警告"
Text3.SetFocus
End If
'信息保存
Rss.AddNew
Rss.Fields(0) = Trim(Text1)
Rss.Fields(1) = Trim(Text2)
Rss.Fields(2) = Trim(Text3)
Rss.Update
MsgBox "保存成功!", vbOKOnly + vbExclamation, "提示"
Rss.Close
End Sub
Private Sub Form_Load()
Dim Rss As New Recordset
Dim Cnn As New Connection
Dim ConnStr As String
Set Cnn = New Connection
ConnStr = "PROVIDER=MSDASQL;dsn=inexport;uid=inexportuser;pwd=65703101;"
Cnn.ConnectionString = ConnStr
Cnn.Open
Set Rss = New Recordset
Rss.Open "select * from LX_QYSC", Cnn, adOpenStatic, adLockOptimistic
End Sub