Setting a queryparam with ADO
กระทู้เก่าบอร์ด อ.สุภาพ ไชยา

 247   1
URL.หัวข้อ / URL
Setting a queryparam with ADO

ถามไว้ที่ http://www.utteraccess.com/forums/showflat.php?Cat=&Board=access_any_version&Number=160084&page=0&view=collapsed&sb=5&o=7&fpart=1&vc=1&PHPSESSID= 
 
เขาเจอตัวอย่างการเปิด Parametered Query โดยใช้โค้ดที่ http://www.mvps.org/access/queries/qry0003.htm 
 
แต่เป็นโค้ดที่ใช้ DAO  
 
เขาต้องการตัวอย่างที่เป็น ADO ผมเลยได้ให้ตัวอย่างนี้กับเขาไป 
 
Sub ADOExecuteParamQuery2() 
 
    Dim cnn  As New ADODB.Connection 
    Dim cmd As New ADODB.Command 
    Dim rst As New ADODB.Recordset 
    Dim fld As ADODB.Field 
     
    ' Open the connection 
    Set cnn = CurrentProject.Connection 
    ' Create the command 
    Set cmd.ActiveConnection = cnn 
    cmd.CommandText = "qryEmployees" 
     
    ' Execute the Command, passing in the values for the parameters 
    Set rst = cmd.Execute(, Array(#8/19/1952#, #8/14/1991#), adCmdStoredProc) 
         
    ' Display the records in the debug window 
    While Not rst.EOF 
        For Each fld In rst.Fields 
            Debug.Print fld.Value & ";"; 
        Next 
        Debug.Print 
        rst.MoveNext 
    Wend 
     
    'Close the recordset 
    rst.Close 
     
End Sub  *** Edited by Supap Chaiya *** 2/9/2546 21:10:15

1 Reply in this Topic. Dispaly 1 pages and you are on page number 1

1 @R06669
   
@ ประกาศใช้งานเว็บบอร์ดใหม่ => บอร์ดเรียนรู้ Access สำหรับคนไทย
แล้วจะใส่ลิ้งอ้างอิงมาที่โพสต์เก่านี้หรือไม่ก็ตามสะดวกครับ
Time: 0.0448s