Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- MysqlConn = New MySqlConnection()
- ' Define the SQL to grab data from table.
- SQL = "SELECT * FROM stock"
- 'Connection String
- MysqlConn.ConnectionString = "server=teamva.000webhostapp.com;" _
- & "user id=XXXXXXXX;" _
- & "password=XXXXXX;" _
- & "database=db_name"
- ' Try, Catch, Finally
- Try
- MysqlConn.Open()
- ContactsCommand.Connection = MysqlConn
- ContactsCommand.CommandText = SQL
- ContactsAdapter.SelectCommand = ContactsCommand
- ContactsAdapter.Fill(ContactsData)
- DataGridView1.DataSource = ContactsData
- Catch myerror As MySqlException
- MessageBox.Show("Cannot connect to database: " & myerror.Message)
- Finally
- MysqlConn.Close()
- MysqlConn.Dispose()
- End Try
- Dim connStr As String = "server=localhost;user=id2653259_rickyuzuriha;database=id2653259_stock;password=******;"
- Dim conn As New MySqlConnection(connStr)
- Try
- Console.WriteLine("Connecting to MySQL...")
- conn.Open()
- 'do your queries'
- Catch ex As Exception
- Console.WriteLine(ex.ToString())
- Finally
- conn.Close()
- Console.WriteLine("Done.")
- End Try
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement