Pages

Banner 468

Kamis, 06 November 2008

Connectionstring ke database access,sqlserver dan mysql

 
'ini code Connectionstring ke database access,sqlserver dan mysql
'copykan code ini d module setelah itu bisa untuk koneksi bisa panggil nama rocedurenya
'Koneksidb(1) '

Public con As New ADODB.Connection
Public ConString As String

Public Sub Koneksidb(inxCon As Integer)
'by : eko cahyono (eko_matrix@yahoo.com)
' ID YM eko_matrix
If con.State = adStateOpen Then con.Close
con.CursorLocation = adUseClient

Select Case inxCon

Case 1 ''***koneksi ke access tanpa password melalui path directory **************
ConString = "Provider=Microsoft.Jet.OLEDB.4.0;Data Source=" & App.Path & _
"\database\salon.mdb;Persist Security Info=False"

Case 2 ''***koneksi ke access dengan password melalui path directory **************
ConString = "Provider=Microsoft.Jet.OLEDB.4.0;Data Source=" & App.Path & _
"\database\salon.mdb;Jet OLEDB:Database Password=MyDbPassword;"

Case 3 '***koneksi sql server *****************
ConString = "Provider=SQLOLEDB.1;Password=" & "" & ";" & _
"Persist Security Info=True;User ID=" & "sa" & _
";Initial Catalog=sirsmojosari" & ";Data Source=" & "127.0.0.1"


Case 4 '***koneksi mysql (harus diinstal driver mysqlOdbc 3.51) *****************
ConString = "DRIVER={mysql ODBC 3.51 driver};SERVER=" & svr & ";" & _
" PORT=3306;DATABASE= " & db & ";" & _
"USER=" & user & ";PASSWORD=" & pws & ";OPTION=3;"
End Select

con.ConnectionString = ConString
con.Open
End Sub