Created
May 24, 2015 05:10
-
-
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)
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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