SQL SERVER
public sub koneksi_sqlserver()
Dim userid As String, userpass As String, namaserver As String, namadb As String
userid = "sa"
userpass = ""
namaserver = ""
namadb = ""
myConn.ConnectionString = "Provider=SQLOLEDB.1;" & _
"Persist Security Info=False;" & _
"User ID=" & userid & ";" & _
"Password=" & userpass & ";" & _
"Initial Catalog=" & namadb & ";" & _
"Data Source=" & namaserver
myConn.ConnectionTimeout = 60
myConn.CursorLocation = adUseClient
myConn.Open
end sub
_________________________________________________________________
MYSQL
Public Sub koneksi_mysql()
Dim db_name As String
Dim db_server As String
Dim db_port As String
Dim db_user As String
Dim db_pass As String
Dim strcon As String
db_name = ""
db_server = "192.168.0.41"
db_port = "3306"
db_user = ""
db_pass = ""
'/buat connection string
strcon = "DRIVER={MySQL ODBC 5.1 Driver};SERVER=" & db_server & ";DATABASE=" & db_name & ";UID=" & db_user & ";PWD=" & db_pass & ";PORT=" & db_port & ";OPTION=3"
Set konek_mysql = New ADODB.Connection
konek_mysql.CursorLocation = adUseClient
konek_mysql.Open strcon
End Sub
__________________________________________________________________
ACCESS
Public Sub koneksi_access()
Dim strFileName As String
Dim strConnString As String
strFileName = FixPath("db2.mdb")
strConnString = "Provider=Microsoft.Jet.OLEDB.4.0;Data Source=" & strFileName & ";Persist Security Info=False"
Set konek_access = New ADODB.Connection
konek_access.CursorLocation = adUseClient
konek_access.Open strConnString
End Sub