I've been working with SQL for a little while and I am starting to explore stored procedures and how to run them from excel vba. I hope this is the forum for this question. I have this script to run a stored procedure called "sp_SelectTForecast" (SP) that retrieves data from a table called tForecast on my local database called "ITMDB"
I think that I have connected to the correct database, and at first the error said could not find the SP, but now the script runs all the way through but the data does not show up on the excel sheet. what am I doing wrong?
Dim conn As ADODB.Connection
Dim cmd As ADODB.Command
Set conn = New ADODB.Connection
conn.ConnectionString = "Provider=SQLOLEDB;Data Source=" & "localhost\sqlexpress" & ";Initial Catalog=" & "ITMDB" & ";User ID=" & "#####" & ";Password=" & "########" & ";Trusted_Connection=yes"
Set cmd = New ADODB.Command
cmd.ActiveConnection = conn
cmd.CommandType = adCmdStoredProc
cmd.CommandText = "sp_SelectTForecast"
Set conn = Nothing
Set cmd = Nothing