ªð¦^¦Cªí ¤W¤@¥DÃD µo©«

[µo°Ý] excel Ū¨úSQL ¸ê®Æ ÅܼƳ]©w

[µ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

²{¦b­n§â DeliveryID ªº 201506160004 §ï¬°¥iÅܪº¡A ¦bÀx¦s®æB3 .
¤]´N¬O ¦bB3¿é¤J¡A´N¥i¶×¤J·Q­n ProductID,SalesQuantity¸ê®Æ¡C
½Ð°Ý¦U¦ì¤j¤j³o¼Ë­n«ç»ò§ï?

¦^´_ 1# mptmk

¤w¸Ñ¨M

TOP

        ÀR«ä¦Û¦b : ®É®É¦n¤ß´N¬O®É®É¦n¤é¡C
ªð¦^¦Cªí ¤W¤@¥DÃD