- ©«¤l
- 2
- ¥DÃD
- 1
- ºëµØ
- 0
- ¿n¤À
- 3
- ÂI¦W
- 0
- §@·~¨t²Î
- win7
- ³nÅ骩¥»
- x64
- ¾\ŪÅv
- 10
- µù¥U®É¶¡
- 2015-6-18
- ³Ì«áµn¿ý
- 2015-6-18
|
[µo°Ý] excel Ū¨úSQL ¸ê®Æ ÅܼƳ]©w
¨Ï¥ÎExcel Ū¨úSQL¸ê®Æªí¤º®e
§â DeliveryID ¬°201506160004 ªºProductID,SalesQuantity¸ê®Æ©ñ¨ì Àx¦s®æI6
¥¨¶°¦p¤U¡G
Sub test2() '©w¸q¹Lµ{¦WºÙ
Dim sht As Worksheet 'sht ¬°excel¤u§@ªíª«¥óÅܼơA«ü¦V¬Y¤@¤u§@ªí
Dim ADOcn As Object
Dim ADOrt As Object
Set ADOcn = CreateObject("ADODB.Connection") '©w¸q¸ê®Æ³sµ²ª«¥ó
Set ADOrt = CreateObject("ADODB.Recordset") '©w¸q°O¿ýª«¥ó
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" '©w¸q¸ê®Æ®w³sµ²¦r¦ê
ADOcn.Open strCn '»P¸ê®Æ®w«Ø¥ß³s±µ¡A¦pªG¦¨¥\¡Aªð¦^³s½uª«¥ócn
strSQL = "select ProductID,SalesQuantity from DeliveryDetail where DeliveryID ='2015061600004'" '©w¸qSQL¬d¸ß©R¥O¦r¦ê¬°
ADOrt.Open strSQL, ADOcn '
Range("I6").CopyFromRecordset ADOrt
ADOrt.Close 'Ãö³¬°O¿ý¶°¡A
ADOcn.Close
End Sub
²{¦bn§â DeliveryID ªº 201506160004 §ï¬°¥iÅܪº¡A ¦bÀx¦s®æB3 .
¤]´N¬O ¦bB3¿é¤J¡A´N¥i¶×¤J·Qn ProductID,SalesQuantity¸ê®Æ¡C
½Ð°Ý¦U¦ì¤j¤j³o¼Ën«ç»ò§ï? |
|