把 DeliveryID 為201506160004 的ProductID,SalesQuantity資料放到 儲存格I6
巨集如下:
Sub test2() '定義過程名稱
Dim sht As Worksheet 'sht 為excel工作表物件變數,指向某一工作表
Dim ADOcn As Object
Dim ADOrt As Object
Set ADOcn = CreateObject("ADODB.Connection") '定義資料連結物件
Set ADOrt = CreateObject("ADODB.Recordset") '定義記錄物件
Dim strCn As String, strSQL As String
strCn = "Provider=SQLOLEDB.1;Password=XXX;Persist Security Info=Tru e;User ID=XXX;Initial Catalog=i-FreelancerSBP-0001;Data Source=(local)\SQLExpress;Use Procedure for Prepare=1;Auto Translate=True;Packet Size=4096;Workstation ID=MARVIN-PC;Use Encryption for Data=False;Tag with column collation when possible=False" '定義資料庫連結字串