存储过程调用出错的问题!高手请进!
vb中调用带两个输入参数(begindate,enddate 均为8位datetime型)的存储过程
运行时出错
代码如下:
Dim cnn1 As ADODB.Connection
Dim command1 As ADODB.Command
Dim parm_begindate As ADODB.Parameter
Dim parm_enddate As ADODB.Parameter
Dim strCnn As String
Private Sub Command1_Click()
Set begindate = New ADODB.Parameter
Set command1 = New ADODB.Command
begindate.Type = adDate
begindate.Size = 8
parm_begindate.Direction = adParamInput
parm_begindate.Value = Format(Text1.Text, "yyyy-mm-dd")
command1.Parameters.Append parm_begindate
Set enddate = New ADODB.Parameter
parm_enddate.Type = adDate
parm_enddate.Size = 8
parm_enddate.Direction = adParamInput
parm_enddate.Value = Format(Text2.Text, "yyyy-mm-dd")
command1.Parameters.Append parm_enddate
command1.ActiveConnection = cnn1
command1.CommandText = "RRR"
command1.CommandType = adCmdStoredProc
End Sub
Private Sub Form_Load()
Set cnn1 = New ADODB.Connection
strCnn = "Provider=SQLOLEDB.1;Persist Security Info=False;User ID=sa;Initial Catalog=SettleDB;Data Source=GNETDATA\GNETDATA"
cnn1.Open strCnn
If cnn1.State <> 1 Then
MsgBox "连接失败"
Exit Sub
End If
End Sub
Private Sub Form_Unload(Cancel As Integer)
cnn1.Close
Set cnn1 = Nothing
End Sub
运行时显示:对象变量或with块变量未设置。
请帮我改一下源程序!