Saatnya Membagi Trik setelah Vakum Berapa Hari sudah gatal untuk menulis artikel di Blogku ,he2 trik kalai ini tentang programan yaitu Membuat ODBC Dengan Fungsi API di VB 6.0 Langsung saja ikuti koding dibawah ini:
Private Declare Function RegSetValueEx_STR Lib "advapi32.dll" Alias "RegSetValueExA" (ByVal hKey As Long, ByVal lpValueName As String, ByVal Reserved As Long, ByVal dwType As Long, ByVal lpData As String, ByVal cbData As Long) As Long
Private Declare Function RegCreateKey Lib "advapi32.dll" Alias "RegCreateKeyA" (ByVal hKey As Long, ByVal lpSubKey As String, phkResult As Long) As Long
Private Declare Function RegCreateKeyEx Lib "advapi32.dll" Alias "RegCreateKeyExA" (ByVal hKey As Long, ByVal lpSubKey As String, ByVal Reserved As Long, ByVal lpClass As String, ByVal dwOptions As Long, ByVal samDesired As Long, ByVal lpSecurityAttributes As Long, ByRef phkResult As Long, ByVal lpdwDisposition As Long) As Long
Private Declare Function RegSetValue Lib "advapi32.dll" Alias "RegSetValueA" (ByVal hKey As Long, ByVal lpSubKey As String, ByVal dwType As Long, ByVal lpData As String, ByVal cbData As Long) As Long
Private Declare Function RegOpenKeyEx Lib "advapi32.dll" Alias "RegOpenKeyExA" (ByVal hKey As Long, ByVal lpSubKey As String, ByVal ulOptions As Long, ByVal samDesired As Long, phkResult As Long) As Long
Private Const HKEY_CURRENT_USER = &H80000001
Private Const KEY_QUERY_VALUE = &H1
Private Const KEY_SET_VALUE = &H2
Private Const KEY_ALL_ACCESS = &H3F
Private Const ERROR_SUCCESS = 0&
Private Const WM_CLOSE = &H10
Private Const REG_BINARY = 3
Private Const REG_SZ = 1
Private Const REG_EXPAND_SZ = 2
Private Const REG_DWORD = 4
Private Const REG_MULTI_SZ = 7
Private Sub Command1_Click()
Dim hROKE As Long
RegCreateKey HKEY_CURRENT_USER, "Software\ODBC\ODBC.INI\test", "0" '
RegOpenKeyEx HKEY_CURRENT_USER, "Software\ODBC\ODBC.INI\test", 0, KEY_ALL_ACCESS, hROKE
RegSetValueEx_STR hROKE, "Driver", 0, REG_SZ, "C:\Program Files\MySQL\Connector ODBC 5.1\myodbc5.dll", Len("C:\Program Files\MySQL\Connector ODBC 5.1\myodbc5.dll")
RegSetValueEx_STR hROKE, "DESCRIPTION", 0, REG_SZ, "Server Ku", Len("Server ku")
RegSetValueEx_STR hROKE, "SERVER", 0, REG_SZ, "localhost", Len("localhost")
RegSetValueEx_STR hROKE, "UID", 0, REG_SZ, "root", Len("root")
RegSetValueEx_STR hROKE, "PWD", 0, REG_SZ, "ibas", Len("ibas")
RegSetValueEx_STR hROKE, "DATABASE", 0, REG_SZ, "test", Len("test")
RegSetValueEx_STR hROKE, "PORT", 0, REG_SZ, "3306", Len("3306")
'''''''''''
RegOpenKeyEx HKEY_CURRENT_USER, "Software\ODBC\ODBC.INI\ODBC Data Sources", 0, KEY_ALL_ACCESS, hROKE
RegSetValueEx_STR hROKE, "test", 0, REG_SZ, "MySQL ODBC 5.1 Driver", Len("MySQL ODBC 5.1 Driver")
MsgBox "ODBC test sukses dibuat"
End Sub
ya odbc diatas mengunakan driver mysql jadinya ya seperti diatas tergantung mana yang mau dibuat tinggal ikuti standart default driver odbc di letakkan
ya cukup sekian dan terima kasih wasalam.