title: correct way to pass as string to CreateParameter
body: <p>If I call a stored procedure by</p>
  
  <pre><code>DECLARE @return_value int
  
  EXEC @return_value = [dbo].[GetValueProc]
    @startDate = '1/1/2010',
    @endDate = '12/31/2010',  
    @groupNo = N'02'
  SELECT 'Return Value' = @return_value
  </code></pre>
  
  <p>From sql command window it works great, but using VB6 it returns an empty record set.</p>
  
  <pre><code>Dim cmd As New ADODB.Command
  Set cmd.ActiveConnection = cn
  
  cmd.CommandText = "GetValueProc"
  cmd.CommandType = adCmdStoredProc
  cmd.Parameters.Append cmd.CreateParameter("@startDate", adDate, adParamInput, 0, startDate)
  cmd.Parameters.Append cmd.CreateParameter("@endDate", adDate, adParamInput, 0, endDate)
  cmd.Parameters.Append cmd.CreateParameter("@groupNo", adVarChar, adParamInput, 3, "02")
  
  Set RstRecordSet = New ADODB.Recordset
  With RstRecordSet        
    .CursorType = adOpenStatic
    .CursorLocation = adUseClient
    .LockType = adLockOptimistic
    .Open cmd
  End With
  </code></pre>
  
  <p>I get an empty Record set from vb. However, from sql command window it works as expected.</p>
  
  <p>Note: If I comment out the line with the parameter in question it also works as expected.</p>
  
  <p>the stored procedure looks like:</p>
  
  <pre><code>ALTER PROCEDURE [dbo].[GetValueProc] 
  @startDate as date,
  @endDate as date,
  @proposalNo nvarchar(30) = null, 
  @groupNo nvarchar(3) = null
  
  select...
  where ...
     and j.[Global Dimension 1 Code] = COALESCE(@groupNo,[Global Dimension 1 Code])
  </code></pre>
  
  <p>[Global Dimension 1 Code] is a varchar(20)</p>
  
  <p>I have also tried</p>
  
  <pre><code>cmd.Parameters.Append cmd.CreateParameter("@groupNo", adVarChar, adParamInput, 4, "'02'")
  </code></pre>
  
  <p>doesn't help.</p>
  
  <p>Any help about the correct way to pass the parameter would be great!</p>
  
  <p>Thanks</p>