Re: Passing Parameter Values in code with Adodc Control

Tech-Archive recommends: Fix windows errors by optimizing your registry

From: Val Mazur (group51a_at_hotmail.com)
Date: 03/18/04


Date: Wed, 17 Mar 2004 21:12:07 -0500

Hi Michael,

I am not using bound controls at all (and do not suggest to use bound
controls to other developers), but I think your code should look something
like

Dim loCommand As ADODB.Command
Dim loParameter As ADODB.Parameter

Set loCommand = New ADODB.Command

loCommand .CommandText="sp_name here"
loCommand.CommandType=adCmdStoredProc

Set loParameter = loCommand.CreateParameter("@company_name", adVarChar, 50)
loParameter.Value = "MyValueHere"

loCommand.Parameters.Append loParameter

Set Adodc1.RecordSource = loCommand

-- 
Val Mazur
Microsoft MVP
"Michael Edwards" <mjenco@hotmail.com> wrote in message 
news:u5%23snn5CEHA.240@tk2msftngp13.phx.gbl...
> Is it possible to pass a parameter value to a stored procedure via VB code
> to an ADO Data Control in VB6?
>
> For example, I have a stored procedure with a varchar(50) parameter
> @company_name. Is there a way to pass a value in code from a string 
> variable
> strCompanyName to the stored procedure attached to the ADO Data Control?
>
> -- 
> Sincerely,
> muDDfish Mike
> http://www.kingmuddfish.com
>
> 


Relevant Pages

  • Re: Data-Bound is BAD???
    ... Corner of my heart i still feel that there is a goldmine in Bound Controls ... > Custom data source controls provide you with almost limitless ... > you can use them to process connection and recordset events, ...
    (microsoft.public.vb.database.ado)
  • Re: Data-Bound is BAD???
    ... Data Bound controls add additional ... Actually what you're describing is a limitation of the stock *data source ... you can use them to process connection and recordset events, ... I realize I'm one of the few advocates of bound controls that regularly ...
    (microsoft.public.vb.database.ado)
  • Re: Last Edited record on Subform.
    ... Sylvain Lafontaine, ing. ... are they bound or unbound controls? ... to change the values in bound controls and update the tables? ... report of bugs with Me.RecordsetClone and ADP. ...
    (microsoft.public.access.adp.sqlserver)
  • Re: Locking bound controls-AllenBrowne
    ... The code toggles the Locked state of the bound controls. ...
    (microsoft.public.access.formscoding)
  • Re: Advanced Queries
    ... Microsoft vs Lyle Fairfield/Larry Linson? ... BTW I have old code that goes through all my forms and renames controls ... specifically ensures that bound controls do have the same name as the ...
    (comp.databases.ms-access)