Error Connecting SQL Server 2005 using Excel VBA

This is the code that I am using
conn.Open "Provider=MSDASQL.1;Server=VISHESH-NC\SQLEXPRESS;Initial Catalog=Northwind;Integrated Security=SSPI;", "abc", "abc"
This gives the error:
Err No. -2147217887
Multiple-step OLE DB operation generated errors. Check each OLE DB status value, if available. No work was done.
on changing the command to
conn.Open "Provider=MSDASQL.1;Server=VISHESH-NC\SQLEXPRESS;Initial Catalog=Northwind;", "abc", "abc"
this throws the following error:
Err No. -2147467259
[Microsoft][ODBC Driver Manager] Data source name not found and no default driver specified
However if I define ODBC DSN and use the following it works fine
conn.Open "Provider=MSDASQL.1;Data Source=abc;Initial Catalog=Northwind;"
Where am I going wrong with my first 2 approaches.
- Add new comment
- 1339 reads

Recent comments
2 hours 31 min ago
4 hours 54 min ago
21 hours 26 min ago
22 hours 34 min ago
22 hours 38 min ago
22 hours 53 min ago
23 hours 51 min ago
1 day 43 min ago
1 day 9 hours ago
1 day 9 hours ago