Skip to content

Instantly share code, notes, and snippets.

@cbedoy
Created May 24, 2015 05:10
Show Gist options
  • Save cbedoy/12499c9102557bee6843 to your computer and use it in GitHub Desktop.
Save cbedoy/12499c9102557bee6843 to your computer and use it in GitHub Desktop.
How to retrive the information from some query with MySQL and VB (vb sucks :c)
Dim cs As String = "Database=testdb;Data Source=localhost;" _
& "User Id=testuser;Password=test623"
Dim stm As String = "SELECT VERSION()"
Dim version As String
Dim conn As MySqlConnection
Try
conn = New MySqlConnection(cs)
conn.Open()
Dim cmd As MySqlCommand = New MySqlCommand(stm, conn)
rd = cmd.ExecuteReader
if rd.read then
//Maybe you have here a pojo object :p
StrVar = rd.GetString(N) //N represent the position of row from your table yourTable(0,1,2,3... N rows)
Catch ex As MySqlException
Console.WriteLine("Error: " & ex.ToString())
Finally
conn.Close()
End Try
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment