• About
  • Contact
  • Sitemap
  • Privacy Policy

Cara Membuat Koneksi ke MySQL dengan Visual Foxpro

 on Wednesday, October 8, 2014  

Pertama buatlah project baru, kemudian pada tab documents buatlah form baru serperti berikut ini :




Atur Properties masing-masing object.

Object
Properti
Nilai
Form1
Caption
Autocenter
ShowWindow
WindowsType
Form Koneksi
.T.-True
1 - In Top-Level Form
1 - Modal
Label1
Caption
BackStyle
Database Name
0 - Transparent
Label2
Caption
BackStyle
User Name
0 - Transparent
Label3
Caption
BackStyle
Password
0 - Transparent
Text1
Name
Maxlength
Special Effect
Border Style
Vdata
40
1-Plain
0-None
Text2
Name
Maxlength
Special Effect
Border Style
Username
40
1-Plain
0-None
Text3
Name
Maxlength
Special Effect
Border Style
Passwd
40
1-Plain
0-None
Command1
Caption
Name
connect


Command1
Command2
Caption
Name
batal


Command2


Buatlah Method dengan nama nilai_awal pada menu form-> New Method,kemjudian buatlah property dengan nama baru, koneksi dan namakursor pada menu form->New Properties.
Kemudian ketikkan code propgram seperti berikut ini :

Object : Form1 Procedure : nilai_awal
THISFORM.vdata.VALUE=" "
THISFORM.username.VALUE=" "
THISFORM.passwd.VALUE=" "
THISFORM.REFRESH
thisform.vdata.SetFocus

Object : Form1 Procedure : Activate
_screen.visible=.f.


Object : vdata Procedure : valid
IF EMPTY( THISFORM.vdata.VALUE )
RETURN 0
ENDIF

Object : username Procedure : valid
IF EMPTY( THISFORM.vdata.VALUE )
RETURN 0
ENDIF

Object : passwd Procedure : valid
IF EMPTY( THISFORM.vdata.VALUE )
RETURN 0
ENDIF

Object : command1 Procedure : click
vdbase = ALLTRIM(thisform.vdata.Value)
vuser = ALLTRIM(thisform.username.Value)
vpass = ALLTRIM(thisform.passwd.Value)
vport = "3306"
mstr = [DRIVER={MySQL ODBC 3.51 Driver};Server=localhost;Port=&vport;Database=&vdbase;User=&vuser;Password=&vpass;]

THISFORM.Koneksi = SQLSTRINGCONNECT( mstr )
IF THISFORM.Koneksi <= 0 =MESSAGEBOX("Koneksi Ke Server Database MySQL Gagal", 0+16, "Konfirmasi") ELSE =MESSAGEBOX("Koneksi Ke Server Database MySQL Berhasil", 0+64, "Konfirmasi") ENDIF THISFORM.namakursor = "QT"+SUBSTR(SYS(2015), 5) thisform.nilai_awal() koneksi = thisform.koneksi namakursor=thisform.namakursor thisform.Release Object : command2 Procedure : click thisform.

Cara Membuat Koneksi ke MySQL dengan Visual Foxpro 4.5 5 Hand Wednesday, October 8, 2014 Pertama buatlah project baru, kemudian pada tab documents buatlah form baru serperti berikut ini : Atur Properties masing-masing objec...


No comments:

Post a Comment

J-Theme