我目前正在尝试在 VB6 中运行某个过程(sql 2005),并传递一些参数:
Dim conn As Connection
Set conn = New Connection
conn.Open "Provider=whateverprovider;Data Source=whateversource;Database=whateverdatabase;User Id=whateverID;Password=whatever"
Dim CMD As ADODB.Command
Dim rs As ADODB.Recordset
Set CMD = New ADODB.Command
Set CMD.ActiveConnection = conn
CMD.CommandType = adCmdStoredProc
CMD.Parameters.Append CMD.CreateParameter("@EmpresaCNPJ", adVarChar, adParamInput, 14, "64687015000152")
CMD.Parameters.Append CMD.CreateParameter("@EntradaSaida", adChar, adParamInput, 1, "S")
CMD.Parameters.Append CMD.CreateParameter("@Participante", adVarChar, adParamInput, 60, "0000000020")
CMD.Parameters.Append CMD.CreateParameter("@nroNotaFiscal", adInteger, adParamInput)
CMD.Parameters("@nroNotaFiscal").Value = 2289
CMD.Parameters.Append CMD.CreateParameter("@serieNotaFiscal", adSmallInt, adParamInput)
CMD.Parameters("@serieNotaFiscal").Value = 1
Set rs = CMD.Execute
在最后一行中,我收到以下错误消息:
替代文字 http://dl.dropbox.com/u/3045472/ERRO.png
它用英文写着:“语法错误或访问冲突”
这条消息真的很笼统,我不知道问题出在哪里。
我做错了什么 ?
下面是过程中sql代码的参数接收部分:
@EmpresaCNPJ varchar(14),
@EntradaSaida char(1)=null,
@Participante varchar(60)=null,
@nroNotaFiscal int=null,
@serieNotaFiscal smallint=null,
@EtapaInicial tinyint=null,
@LineComplement varchar(255)=null
有人告诉我,不是每个参数都应该传递,它应该只使用五个(七个)。