title: Fail to run sp_prepare over ADODB from Visual Basic
body: <p>I can't get the handle value to pass to sp_execute. If I use the SQL code directly with Management Studio I succeed:</p>
  
  <pre><code>Declare @handle Integer
  exec sp_prepare @handle OUTPUT, N'@year int', N'SELECT * from Sales.CreditCard where ExpYear=@year';
  
  select @handle
  
  exec sp_execute @handle, 2007
  exec sp_unprepare @handle
  </code></pre>
  
  <p>but when I try the following code on VB, "param3.Value" is "nothing" after the command is executed.</p>
  
  <pre><code>    ConnString = "DRIVER={SQL Server};SERVER=192.168.100.41,1433;UID=sa;PWD=&lt;password&gt;;DATABASE=AdventureWorks"
      'create an instance of the ADO connection
      Connection = CreateObject("ADODB.Connection")
  
      'Open the connection to the database
      Connection.Open(ConnString)
      Dim cmd As ADODB.Command
      Dim param1 As ADODB.Parameter
      Dim param2 As ADODB.Parameter
      Dim param3 As ADODB.Parameter
  
      cmd = CreateObject("ADODB.Command")
      cmd.ActiveConnection = Connection
      cmd.CommandText = "sp_prepare"
  
      param1 = cmd.CreateParameter("@handle", 3, 2, 4, 0)
      param2 = cmd.CreateParameter("@params", 202, 1, 200, "@year Integer")
      param3 = cmd.CreateParameter("stmt", 202, 1, 200, "SELECT TOP 4 [CreditCardID],[CardType],[CardNumber],[ModifiedDate]  FROM [AdventureWorks].[Sales].[CreditCard] where [ExpYear] in (@year)")
  
      cmd.Parameters.Append(param1)
      cmd.Parameters.Append(param2)
      cmd.Parameters.Append(param3)
  
      cmd.Execute()
  
      Debug.WriteLine("handle:" &amp; param1.Value)
  </code></pre>
  
  <p>Do you know how to make it work on VB?
  The reason I run this from VB is that I need the command to be run over RPC.</p>