BMS-HOSxP Community
HOSxP => Development => ข้อความที่เริ่มโดย: doramon ที่ กรกฎาคม 06, 2008, 16:39:38 PM
-
ตัวอยางบางตอนครับ :
Local Conn As ADODB.Connection
Local Rs As ADODB.Recordset
Conn=Createobject("ADODB.Connection")
Rs =Createobject("ADODB.Recordset")
If Conn.State=1 Then
Conn.Close()
Endif
Conn.ConnectionString="Driver={MySQL ODBC 3.51 Driver};Server=localhost;Database=sample;uid=root;pwd=admin;charset=tis620"
Conn.CommandTimeout=90
Conn.Open
Local sqlCmd As String
sqlCmd="Select * From book"
If rs.State=1 Then
rs.Close()
Endif
rs.ActiveConnection=Conn
rs.CursorLocation= 3 && adUseClient
rs.CursorType= 0 && adOpenForwardOnly
rs.LockType= 1 && adLockReadOnly
rs.Open(sqlCmd)
If rs.RecordCount >0 Then
DO WHILE NOT rs.EOF()
Wait Window rs.Fields(1).Value
rs.MoveNext
ENDDO
Endif
-
อาจารย์อ็อด ช่วยอธิบายต่อด้วยนะครับ ผมสนใจเรื่อง VFP9 + MySQL ครับ
สนใจจริง ๆ ครับ อยากศึกษาครับ
-
อาจารย์อ็อด มีคำถามแล้วประสิทธิภาพการดึงข้อมูลผ่าน mysql เป็นอะไร เพราะว่าตอนนี้ผมใช้ VFP9+MYSQL อยู่ขณะนี้
-
หรือจะลองทำแบบ ODBC
ตัวอย่างรายงาน 504
_server='192.168.0.1'
_user='sa'
_psw='sa'
_database='hos'
_connect = ;
"Driver={MySQL ODBC 3.51 Driver};" + ;
"Server=" + _server + ";" + ;
"UID=" + _user + ";" + ;
"PASSWORD=" + _psw + ";" + ;
"Database="+_database+";" +;
"Port=3306;" + ;
"Option= 0 ;"+;
"Stmt =set names tis620;"
_handle=sqlstringconnect(_connect)
If _handle>0
_sql=[select a.*,ifnull(d.amount,0) as amount from rpt_504_name a left join ]+;
[(select b.id,count(b.id) as amount from rpt_504_code b,ovstdiag c ]+;
[where c.icd10 between b.code1 and b.code2 and c.icd10 is not null ]+;
[and c.vstdate between '2008-1-1' and '2008-1-31' ]+;
[group by b.id) d on d.id=a.id ]+;
[order by a.id ]
if sqlexec(_handle,_sql,'TEMP')>0
brow &&แสดงข้อมูลที่คำนวณได้
else
=aeeror(test)
=messagebox('คำสั่ง SQL ผิด',0,'Error')
endif
=sqldisconnect(_handle)
else
=aerror(test)
=messagebox('ติดต่อ HOSxP ไม่ได้'+chr(13)+test(1,2),0,'Error')
endif
ควรใช้ MySQL ODBC Driver vesion 3.51.15 ขึ้นไป