Thank you so much!!!! It works. I made some changes to the loops to locate the data exactly where I wanted.
Thank you again. On Tuesday, March 25, 2014 5:41:34 PM UTC-4, Rafael DeLeon wrote: > > > Hello all, > > I have a SQL Server Database with a store procedure that I would like to > display in excel. I’m able to connect to the database through excel using > VBA, but don’t know how to display the information in a spreadsheet. Any > help or idea will be appreciated. > > Thank you, > Rafael > > > Bellow the code that already works: > Sub GetData() > > Dim con As ADODB.Connection > Dim cmd As ADODB.Command > Dim rs As ADODB.Recordset > Dim par As String > > Set con = New ADODB.Connection > Set cmd = New ADODB.Command > Set rs = New ADODB.Recordset > > Application.DisplayStatusBar = True > Application.StatusBar = "Contacting to SQL Server..." > > ' Log into SQL Server, and run the Stored Procedure > con.Open "Provider=SQLOLEDB.1;Password=*******;Persist Security > Info=True;User ID=password;Initial Catalog=DataTest;Data > Source=192.168.2.196\Test" > > cmd.ActiveConnection = con > > Dim prmCustomerID As ADODB.Parameter > > ' Set up the parameters > > cmd.Parameters.Append cmd.CreateParameter("@From", adDate, adParamInput, > 10, Range("B4").Text) > cmd.Parameters.Append cmd.CreateParameter("@To", adDate, adParamInput, 10, > Range("B5").Text) > > Application.StatusBar = "Pulling data from Store Procedure" > cmd.CommandText = "spParticipationRpt" > Set rs = cmd.Execute(, , adCmdStoredProc) > > ‘Need help here to do something with the data collected from Sql Server > > rs.Close > Set rs = Nothing > Set cmd = Nothing > con.Close > Set con = Nothing > > Application.StatusBar = "Process completed successfully." > > End Sub <w:LsdException L > ... -- Are you =EXP(E:RT) or =NOT(EXP(E:RT)) in Excel? And do you wanna be? It’s =TIME(2,DO:IT,N:OW) ! Join official Facebook page of this forum @ https://www.facebook.com/discussexcel FORUM RULES 1) Use concise, accurate thread titles. Poor thread titles, like Please Help, Urgent, Need Help, Formula Problem, Code Problem, and Need Advice will not get quick attention or may not be answered. 2) Don't post a question in the thread of another member. 3) Don't post questions regarding breaking or bypassing any security measure. 4) Acknowledge the responses you receive, good or bad. 5) Jobs posting is not allowed. 6) Sharing copyrighted material and their links is not allowed. NOTE : Don't ever post confidential data in a workbook. Forum owners and members are not responsible for any loss. --- You received this message because you are subscribed to the Google Groups "MS EXCEL AND VBA MACROS" group. To unsubscribe from this group and stop receiving emails from it, send an email to excel-macros+unsubscr...@googlegroups.com. To post to this group, send email to excel-macros@googlegroups.com. Visit this group at http://groups.google.com/group/excel-macros. For more options, visit https://groups.google.com/d/optout.