.::REEZHAL SPACE::.

24September 2009

Membuat koneksi VB dengan MYSQL

Filed under: Default

Kali ini saya akan membuat contoh koneksi VB dengan MYSQL yang selama ini saya gunakan dan hingga saat ini belum menemukan kekurangan. Beikut contoh code untuk koneksi nya :

Tambah kan sebuah module baru. Pada modul tersebut isi kan code berikut :

Public Koneksi As ADODB.Connection
Public rsResult As ADODB.Recordset

function LoadKoneksi() as boolean

Set Koneksi = New ADODB.Connection

On Error GoTo Gagal

Koneksi.CommandTimeout = 60
Koneksi.Open "DRIVER={MySQL};SERVER=localhost;DATABASE=koperasi;UID=root;PWD="

LoadKoneksi=True

Exit Function

Gagal:

LoadKoneksi=False

end function

‘———–FUNGSI QUERY——————-

function Query(QString as String) as Boolean

On Error GoTo Gagal
    Set rsResult = New ADODB.Recordset
    rsResult.CursorLocation = adUseClient
    rsResult.Open QString, Koneksi, adOpenDynamic, adLockOptimistic
    Query = True
    Exit Function


Gagal:

Query=False

End Function

Catatan : Tulisan MySQL yang berwarna merah adallah Driver MYSQL. Disini saya menggunakan MYSQL Connector..

 

Comments

The URI to TrackBack this entry is: http://rizhal.blogsome.com/2009/09/24/membuat-koneksi-vb-dengan-mysql/trackback/

No comments yet.

RSS feed for comments on this post.

Leave a comment

Sorry, the comment form is closed at this time.


Get free blog up and running in minutes with Blogsome
Theme designed by Jay of onefinejay.com

free hit counter
free hit counter