'判断是否存在存储过程
If Db.Execute("select * from sysobjects where id=object_id(N'Sto_A1') and objectproperty(id,N'IsProcedure')=1").EOF Then
'不存在,就新建
Sql = "create Procedure Sto_A1" & vbCrLf & _
"as" & vbCrLf & _
"select * from syscolumns"
Db.Execute Sql
End If
End Sub
'在出错时新建
Sub test2()
Dim Db As New ADODB.Connection
Db.Execute ("sto_a1")
Exit Sub
lbErr:
If Err = -2147217900 Then
'不存在时
test1
Else
MsgBox "错误:" & Error & vbCrLf & "错误号:" & Err
'你的第二个问题,可以在这里通过err来获得错误号
End If
End Sub