Results 1 to 8 of 8

Thread: executing a stored query

  1. #1

    Thread Starter
    Bouncy Member darre1's Avatar
    Join Date
    May 2001
    Location
    Peterborough, UK
    Posts
    3,828

    Unhappy executing a stored query

    not having a good day today

    i'm trying to execute a stored query (update query) in a access 2000 database with the following code.

    VB Code:
    1. Set comUpdate = New Command
    2.     comUpdate.CommandType = adCmdStoredProc
    3.     comUpdate.CommandText = "qryUPDWeeklyDataFile"
    4.     comUpdate.Parameters.Append comUpdate.CreateParameter("parPublisher", adBSTR, _
    5.         adParamInput, , com.Parameters("parPublisher"))
    6.     comUpdate.Parameters.Append comUpdate.CreateParameter("parWeekYear", adBSTR, _
    7.         adParamInput, , com.Parameters("parWeekYear"))
    8.     comUpdate.ActiveConnection = cnTemp
    9.     comUpdate.Execute
    10.     Set comUpdate = Nothing

    i've stepped through it and it goes straight through the code, no problems, no errors etc, but when i look at the records in the datdabase using access, nothing has changed.

    NOTE: I had ran the query manually using access and specified the exact same parameter values (checked them using the immediate window) and it worked perfectly.

    i'm lost!

    Confucious say, "Man standing naked in biscuit barrel not necessarily ****ing crackers."

    Don't forget to format your code in your posts

  2. #2

    Thread Starter
    Bouncy Member darre1's Avatar
    Join Date
    May 2001
    Location
    Peterborough, UK
    Posts
    3,828
    nobody got a clue?

    Confucious say, "Man standing naked in biscuit barrel not necessarily ****ing crackers."

    Don't forget to format your code in your posts

  3. #3

    Thread Starter
    Bouncy Member darre1's Avatar
    Join Date
    May 2001
    Location
    Peterborough, UK
    Posts
    3,828
    sokay i've sorted it now.

    just used a nice long messy SQL statement instead
    Confucious say, "Man standing naked in biscuit barrel not necessarily ****ing crackers."

    Don't forget to format your code in your posts

  4. #4
    Addicted Member djengiz's Avatar
    Join Date
    Jan 2001
    Location
    The Netherlands
    Posts
    153
    Have you defined the parameters in your stored procedure in Access?

  5. #5
    Addicted Member djengiz's Avatar
    Join Date
    Jan 2001
    Location
    The Netherlands
    Posts
    153
    try this

    VB Code:
    1. Dim objCon As ADODB.Connection
    2. Set objCon = New ADODB.Connection
    3. objCon.Open "PROVIDER=Microsoft.Jet.OLEDB.4.0;Data Source=c:\bla.mdb;"
    4.  
    5. Dim cmd As ADODB.Command
    6. Dim rs As ADODB.Recordset
    7. Set cmd = CreateObject("ADODB.Command")
    8. With cmd
    9.     .CommandType = adCmdUnknown 'access does not know Store Procedure
    10.     .CommandText = "your_procedure"
    11.     .Parameters.Append .CreateParameter("param_1", adDouble, adParamInput, , <value of param_1>)
    12.     .Parameters.Append .CreateParameter("param_2", adDouble, adParamInput, , <value of param_1>)
    13.     .ActiveConnection = objCon
    14.     Set rs = .Execute
    15. End With
    16. rs.Close
    17. Set rs = Nothing
    18. Set cmd = Nothing
    19. objCon.Close
    20. Set objCon = Nothing

  6. #6

    Thread Starter
    Bouncy Member darre1's Avatar
    Join Date
    May 2001
    Location
    Peterborough, UK
    Posts
    3,828
    i didn't know this bit :

    ".CommandType = adCmdUnknown 'access does not know Store Procedure
    "

    but i've been messing about with it for hours now, and i got it working just by using SQL so i'm gonna leave it for now
    Confucious say, "Man standing naked in biscuit barrel not necessarily ****ing crackers."

    Don't forget to format your code in your posts

  7. #7
    Addicted Member djengiz's Avatar
    Join Date
    Jan 2001
    Location
    The Netherlands
    Posts
    153
    Sorry I didnt see your post earlier

  8. #8

    Thread Starter
    Bouncy Member darre1's Avatar
    Join Date
    May 2001
    Location
    Peterborough, UK
    Posts
    3,828
    that's ok, your way sounds like your on the right track, i didnt know that bit anyway
    Confucious say, "Man standing naked in biscuit barrel not necessarily ****ing crackers."

    Don't forget to format your code in your posts

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