Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- Imports MySql.Data.MySqlClient.MySqlConnection
- Imports System.Data
- Module mdlKoneksi
- '-- MySQL Connection
- Public connDB As New MySql.Data.MySqlClient.MySqlConnection
- Public comDB As New MySql.Data.MySqlClient.MySqlCommand
- Public comBuilderDB As New MySql.Data.MySqlClient.MySqlCommandBuilder
- Public rdDB As MySql.Data.MySqlClient.MySqlDataReader
- Public da As MySql.Data.MySqlClient.MySqlDataAdapter
- Public dt As New DataTable
- Public myError As MySql.Data.MySqlClient.MySqlError
- Public SQL As String
- Public Item As ListViewItem
- Public Sub conecDB()
- 'This is the connection for your MS SQL Server
- 'Dim strServer As String = "" 'This is the server IP/Server name. If server is intalled on your local machine, your IP should be 127.0.0.1 or you may use localhost
- Dim strServer As String = "localhost"
- Dim strDbase As String = "test" 'Database name
- Dim strUser As String = "test" 'Database user
- Dim strPass As String = "abc123" 'Database password
- 'MySQL Connection String
- If connDB.State <> ConnectionState.Open Then connDB.ConnectionString = "server=" & strServer.Trim & ";database=" & strDbase.Trim & ";user=" & strUser.Trim & ";password=" & strPass
- If connDB.State <> ConnectionState.Open Then connDB.Open()
- End Sub
- 'Close the connection from database
- Public Sub closeDB()
- If connDB.State <> ConnectionState.Closed Then connDB.Close()
- End Sub
- 'Initialize the sql command object
- Public Sub initCMD()
- With comDB
- .Connection = connDB
- .CommandType = CommandType.Text
- .CommandTimeout = 0
- End With
- End Sub
- End Module
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement