2017-04-07 70 views

回答

1

這裏是關於Dany Hoter關於VBA的blogged。在C#中應該是一個很好的模式:

Sub AddSQLtables() 

‘One or more tables from a SQL server database 

‘Relationships are detected if they are declared in the database 

ActiveWorkbook.Connections.Add2 _ 

「Connection Name」, 「」, _ 

「OLEDB;Provider=SQLOLEDB.1;Integrated Security=SSPI;Persist Security Info=True;Data Source=<SQL server – name>;Use Procedure for Prepare=1;Auto Translate=True;Packet Size=4096;Use Encryption for Data=False;Tag with column collation when possible=False;Initial Catalog=AdventureWorksDW2008R2」 _ 

, 「」」DimCustomer」」,」」DimGeography」」」, 6, True, True 

End Sub 
+0

太棒了。不知何故,我預計它會更復雜。 Dany Hoter鏈接也非常有用。謝謝 - 非常感謝。 – COG