2017-04-07 41 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

相关问题