Results 1 to 2 of 2

Thread: getting records from storedprocedure in recordset in excel vba

  1. #1

    Thread Starter
    Lively Member
    Join Date
    Jul 2008
    Posts
    73

    getting records from storedprocedure in recordset in excel vba

    Set cmd = New ADODB.Command

    cmd.CommandType = adCmdStoredProc
    Set cmd.ActiveConnection = Module1.conn
    cmd.CommandText = "spEmergencyItemHelp"

    Set prm = cmd.CreateParameter("@ID", adInteger, adParamInput, 255, 12)
    cmd.Parameters.Append prm

    Set prm = cmd.CreateParameter("@Type", adChar, adParamInput, 255, "A")
    cmd.Parameters.Append prm

    Set rst = cmd.Execute()
    Do Until rst.EOF


    Set Sheet1.VSFlexGrid1.DataSource = rst
    rst.MoveNext
    Loop

    i am trying to execute a stored procedure from sql2005 from excel vba get the records in recordset & assign it to grid
    but i get error
    run time error 3709 application defined or object defined error

  2. #2
    Frenzied Member KGComputers's Avatar
    Join Date
    Dec 2005
    Location
    Cebu, PH
    Posts
    2,024

    Re: getting records from storedprocedure in recordset in excel vba

    What's the underlying value/code of Module1.conn?

    I believe this is the connection string right?

    KG
    CodeBank: VB.NET & C#.NET | ASP.NET
    Programming: C# | VB.NET
    Blogs: Personal | Programming
    Projects: GitHub | jsFiddle
    ___________________________________________________________________________________

    Rating someone's post is a way of saying Thanks...

Tags for this Thread

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