Results 1 to 12 of 12

Thread: [RESOLVED] ADO parameters.. in query

  1. #1

    Thread Starter
    PowerPoster Static's Avatar
    Join Date
    Oct 2000
    Location
    Rochester, NY
    Posts
    9,390

    Resolved [RESOLVED] ADO parameters.. in query

    How do I pass in Params to a regular Recordset query??

    the query that the data is pulling from is like this:

    PARAMETERS c_CILLI Text ( 255 );
    SELECT Fields.... etc

    there are about 10 more queries after this that finally feed a union query that I am pulling off of....

    So.. my query is

    "SELECT * INTO tbl_temp_data FROM quniTABLE"

    now.. it wants the param...? how do I pass it in?
    JPnyc rocks!! (Just ask him!)
    If u have your answer please go to the thread tools and click "Mark Thread Resolved"

  2. #2
    Ex-Super Mod RobDog888's Avatar
    Join Date
    Apr 2001
    Location
    LA, Calif. Raiders #1 AKA:Gangsta Yoda™
    Posts
    60,709

    Re: ADO parameters.. in query

    Create a Command Object and pass the parameters that way.
    VB/Office Guru™ (AKA: Gangsta Yoda®)
    I dont answer coding questions via PM. Please post a thread in the appropriate forum.

    Microsoft MVP 2006-2011
    Office Development FAQ (C#, VB.NET, VB 6, VBA)
    Senior Jedi Software Engineer MCP (VB 6 & .NET), BSEE, CET
    If a post has helped you then Please Rate it!
    Reps & Rating PostsVS.NET on Vista Multiple .NET Framework Versions Office Primary Interop AssembliesVB/Office Guru™ Word SpellChecker™.NETVB/Office Guru™ Word SpellChecker™ VB6VB.NET Attributes Ex.Outlook Global Address ListAPI Viewer utility.NET API Viewer Utility
    System: Intel i7 6850K, Geforce GTX1060, Samsung M.2 1 TB & SATA 500 GB, 32 GBs DDR4 3300 Quad Channel RAM, 2 Viewsonic 24" LCDs, Windows 10, Office 2016, VS 2019, VB6 SP6

  3. #3

    Thread Starter
    PowerPoster Static's Avatar
    Join Date
    Oct 2000
    Location
    Rochester, NY
    Posts
    9,390

    Re: ADO parameters.. in query

    ok.. maybe I did it worng.. but It didnt work!??

    lemme try again
    JPnyc rocks!! (Just ask him!)
    If u have your answer please go to the thread tools and click "Mark Thread Resolved"

  4. #4

    Thread Starter
    PowerPoster Static's Avatar
    Join Date
    Oct 2000
    Location
    Rochester, NY
    Posts
    9,390

    Re: ADO parameters.. in query

    doesnt like it?? did I do this wrong?

    VB Code:
    1. Dim rst As New Recordset
    2. Dim cmd As New ADODB.Command
    3. Dim param As New ADODB.Parameter
    4. Dim tmp() As String
    5. Dim SQL As String
    6.  
    7. tmp = Split(cboCILLI, " - ")
    8. SQL = "SELECT COLLO, CILLI, COLLO_NAME, ADDRESS, SWITCH, ILEC_ZONE, " & _
    9.         "TRO_DS1_LOOP , TRO_TIER1, NET_ONOFF, T1, TRUNK_MUX, MILES " & _
    10.         "Into tbl_temp_COLLO_DATA " & _
    11.         "FROM quniCOLLO_DATA"
    12.  
    13. param.Name = "c_CILLI"
    14. param.Value = tmp(0)
    15. param.Type = adVarChar
    16.  
    17. CNN.Execute "DROP TABLE tbl_temp_COLLO_DATA"
    18. cmd.ActiveConnection = CNN
    19. cmd.CommandText = SQL
    20. cmd.CommandType = adCmdText
    21. cmd.Parameters.Append param
    22.  
    23. Set rst = cmd.Execute
    JPnyc rocks!! (Just ask him!)
    If u have your answer please go to the thread tools and click "Mark Thread Resolved"

  5. #5
    Ex-Super Mod RobDog888's Avatar
    Join Date
    Apr 2001
    Location
    LA, Calif. Raiders #1 AKA:Gangsta Yoda™
    Posts
    60,709

    Re: ADO parameters.. in query

    This is an Access db or a SQL server db?
    VB/Office Guru™ (AKA: Gangsta Yoda®)
    I dont answer coding questions via PM. Please post a thread in the appropriate forum.

    Microsoft MVP 2006-2011
    Office Development FAQ (C#, VB.NET, VB 6, VBA)
    Senior Jedi Software Engineer MCP (VB 6 & .NET), BSEE, CET
    If a post has helped you then Please Rate it!
    Reps & Rating PostsVS.NET on Vista Multiple .NET Framework Versions Office Primary Interop AssembliesVB/Office Guru™ Word SpellChecker™.NETVB/Office Guru™ Word SpellChecker™ VB6VB.NET Attributes Ex.Outlook Global Address ListAPI Viewer utility.NET API Viewer Utility
    System: Intel i7 6850K, Geforce GTX1060, Samsung M.2 1 TB & SATA 500 GB, 32 GBs DDR4 3300 Quad Channel RAM, 2 Viewsonic 24" LCDs, Windows 10, Office 2016, VS 2019, VB6 SP6

  6. #6

    Thread Starter
    PowerPoster Static's Avatar
    Join Date
    Oct 2000
    Location
    Rochester, NY
    Posts
    9,390

    Re: ADO parameters.. in query

    sorry

    Error:
    3708
    Parameter object is improperly defined. Inconsistant or Incomplete information was provided
    JPnyc rocks!! (Just ask him!)
    If u have your answer please go to the thread tools and click "Mark Thread Resolved"

  7. #7

    Thread Starter
    PowerPoster Static's Avatar
    Join Date
    Oct 2000
    Location
    Rochester, NY
    Posts
    9,390

    Re: ADO parameters.. in query

    Access
    JPnyc rocks!! (Just ask him!)
    If u have your answer please go to the thread tools and click "Mark Thread Resolved"

  8. #8
    Ex-Super Mod RobDog888's Avatar
    Join Date
    Apr 2001
    Location
    LA, Calif. Raiders #1 AKA:Gangsta Yoda™
    Posts
    60,709

    Re: ADO parameters.. in query

    What is the error?
    VB/Office Guru™ (AKA: Gangsta Yoda®)
    I dont answer coding questions via PM. Please post a thread in the appropriate forum.

    Microsoft MVP 2006-2011
    Office Development FAQ (C#, VB.NET, VB 6, VBA)
    Senior Jedi Software Engineer MCP (VB 6 & .NET), BSEE, CET
    If a post has helped you then Please Rate it!
    Reps & Rating PostsVS.NET on Vista Multiple .NET Framework Versions Office Primary Interop AssembliesVB/Office Guru™ Word SpellChecker™.NETVB/Office Guru™ Word SpellChecker™ VB6VB.NET Attributes Ex.Outlook Global Address ListAPI Viewer utility.NET API Viewer Utility
    System: Intel i7 6850K, Geforce GTX1060, Samsung M.2 1 TB & SATA 500 GB, 32 GBs DDR4 3300 Quad Channel RAM, 2 Viewsonic 24" LCDs, Windows 10, Office 2016, VS 2019, VB6 SP6

  9. #9
    Ex-Super Mod RobDog888's Avatar
    Join Date
    Apr 2001
    Location
    LA, Calif. Raiders #1 AKA:Gangsta Yoda™
    Posts
    60,709

    Re: ADO parameters.. in query

    Probably needing to specify the storedproc property.
    VB Code:
    1. Set goRs = New ADODB.Recordset
    2.     Set oCM = New ADODB.Command
    3.     With oCM
    4.         .ActiveConnection = goEnv.Cnn
    5.         .CommandType = adCmdStoredProc
    6.         .CommandText = sSP_Name
    7.         .Prepared = True
    8.         .Parameters.Append .CreateParameter("@Where", adChar, adParamInput, 10, Mid$(sWhere, 2))
    9.     End With
    10.     goRs.CursorLocation = adUseClient
    11.     goRs.Open oCM, , adOpenKeyset, adLockOptimistic, adCmdStoredProc
    12.     Set Exec_SPrRS = goRs
    VB/Office Guru™ (AKA: Gangsta Yoda®)
    I dont answer coding questions via PM. Please post a thread in the appropriate forum.

    Microsoft MVP 2006-2011
    Office Development FAQ (C#, VB.NET, VB 6, VBA)
    Senior Jedi Software Engineer MCP (VB 6 & .NET), BSEE, CET
    If a post has helped you then Please Rate it!
    Reps & Rating PostsVS.NET on Vista Multiple .NET Framework Versions Office Primary Interop AssembliesVB/Office Guru™ Word SpellChecker™.NETVB/Office Guru™ Word SpellChecker™ VB6VB.NET Attributes Ex.Outlook Global Address ListAPI Viewer utility.NET API Viewer Utility
    System: Intel i7 6850K, Geforce GTX1060, Samsung M.2 1 TB & SATA 500 GB, 32 GBs DDR4 3300 Quad Channel RAM, 2 Viewsonic 24" LCDs, Windows 10, Office 2016, VS 2019, VB6 SP6

  10. #10
    PowerPoster
    Join Date
    Oct 2002
    Location
    British Columbia
    Posts
    9,758

    Re: ADO parameters.. in query

    To execute the Parameter Query use

    VB Code:
    1. With cmd
    2.     .CommandText = "[quniCOLLO_DATA]"
    3. [B]    .CommandType = adCmdTable[/B] 'adCmdUnknown when specifying a Select List
    4.     .Parameters.Append .CreateParameter("@Parm1", adVarChar, adParamInput,255 , Mid$(sWhere, 2))
    5.     Set .ActiveConnection = db
    6.     Set rs = .Execute
    7. End With

    To use the Parameter Query as a dataset to another query use

    VB Code:
    1. With cmd
    2.     .CommandText = "Select * Into tblTempDate From [quniCOLLO_DATA]"
    3. [B]    .CommandType = adCmdUnknown[/B]
    4.     .Parameters.Append .CreateParameter("@Parm1", adVarChar, adParamInput,255 , Mid$(sWhere, 2))
    5.     Set .ActiveConnection = db
    6.     .Execute , , adExecuteNoRecords
    7. End With


    Parameter object is improperly defined. Inconsistant or Incomplete information was provided
    You must specify the Size property of the Parameter object when its data type is variable length.
    Last edited by brucevde; Mar 6th, 2006 at 01:06 PM.

  11. #11
    Ex-Super Mod RobDog888's Avatar
    Join Date
    Apr 2001
    Location
    LA, Calif. Raiders #1 AKA:Gangsta Yoda™
    Posts
    60,709

    Re: ADO parameters.. in query

    Oops for got to change that as I pulled the code from a project of mine.
    VB/Office Guru™ (AKA: Gangsta Yoda®)
    I dont answer coding questions via PM. Please post a thread in the appropriate forum.

    Microsoft MVP 2006-2011
    Office Development FAQ (C#, VB.NET, VB 6, VBA)
    Senior Jedi Software Engineer MCP (VB 6 & .NET), BSEE, CET
    If a post has helped you then Please Rate it!
    Reps & Rating PostsVS.NET on Vista Multiple .NET Framework Versions Office Primary Interop AssembliesVB/Office Guru™ Word SpellChecker™.NETVB/Office Guru™ Word SpellChecker™ VB6VB.NET Attributes Ex.Outlook Global Address ListAPI Viewer utility.NET API Viewer Utility
    System: Intel i7 6850K, Geforce GTX1060, Samsung M.2 1 TB & SATA 500 GB, 32 GBs DDR4 3300 Quad Channel RAM, 2 Viewsonic 24" LCDs, Windows 10, Office 2016, VS 2019, VB6 SP6

  12. #12

    Thread Starter
    PowerPoster Static's Avatar
    Join Date
    Oct 2000
    Location
    Rochester, NY
    Posts
    9,390

    Re: ADO parameters.. in query

    ok.. I couldnt get it to work with a select list.. but when I used the mak table query name it work perfectly! thanks!
    JPnyc rocks!! (Just ask him!)
    If u have your answer please go to the thread tools and click "Mark Thread Resolved"

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •  



Click Here to Expand Forum to Full Width