I'm currently trying to run a certain procedure (sql 2005) in VB6, passing some parameters:
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
In the last line i get the following error message:
Which in English it reads: "syntax error or access violation"
This message is REALLY generic, and I don't have a clue about where could the problem be.
What did i do wrong ?
Here is the parameter receiving part of the sql code in the procedure:
@EmpresaCNPJ varchar(14),
@EntradaSaida char(1)=null,
@Participante varchar(60)=null,
@nroNotaFiscal int=null,
@serieNotaFiscal smallint=null,
@EtapaInicial tinyint=null,
@LineComplement varchar(255)=null
I was told that not every parameter should be passed, and that it should work with just five (out of seven).