Hi all, I'm am wanting to pull some data from a table in a Microsoft SQL server db, and import it into a excel sheet. I currently am using this code:
Code:
Sub Pull_JobNumbers() Dim qt As QueryTable sqlstring1 = "select JOBNUMBER from TABLENAME" connstring = "Driver={SQL Server};Server=SERVER;Database=test1;Uid=sa;Pwd=blah" With ActiveSheet.QueryTables.Add(Connection:=connstring, Destination:=Range("A2"), Sql:=sqlstring1) .Refresh End With End Sub
When I run this macro, I just get a error that says "400". I'm wondering if there is a problem with my connection string, or the code in general?? Everything else seems okay to me, where do I begin troubleshooting this? Thank you for any help!