Welcome!

Join our community of MMO enthusiasts and game developers! By registering, you'll gain access to discussions on the latest developments in MMO server files and collaborate with like-minded individuals. Join us today and unlock the potential of MMO server development!

Join Today!

vb.NET retrieve mysql table data and make it a labels text

Junior Spellweaver
Joined
Oct 26, 2007
Messages
108
Reaction score
0
Hello everyone :) I've been making a game using vb.net 2010 EE and have gotten to the part where I want to save/load all of the game data eg, money

Up to now I have created my registration system and gotten it to login successfully by selecting usernames and passwords.

Now though I am trying to retrieve the information I have in my database and have the text display in a label.

I've tried to do this a few ways but cannot figure out how to only get the data from a row which has the username thats logged in.

I have it so it also fills a datagridview as I tried it that way but I still cant figure out how to select specific cells


Code:
Dim SQLCOM As String = "SELECT * FROM users"

'this is the string im trying to get my value with. I dont know how to make it select a value from a column where the row is username and then write that value as a label

Dim GetGames As String = "SELECT * FROM users WHERE username='" & LBL_loggedinuser.Text & "'"
 
           Dim sqlCommand As New MySqlCommand
            Dim adapter As MySqlDataAdapter
            Dim table As DataTable
            Dim connectionstring As String = "server=*******; user id=gamedev; password=******; database=gamedev;"


            Try
                adapter = New MySqlDataAdapter(SQLCOM, connectionstring)
                table = New DataTable
                adapter.Fill(table)
                DataGridView1.DataSource = table


            Catch ex As Exception
                MsgBox(ex.ToString)
            End Try
 
Newbie Spellweaver
Joined
Dec 4, 2009
Messages
73
Reaction score
4
Code:
Not so good in VB but I guess it would be something like this...

for i = 0 to table.Rows.Count
 Dim lbl as Label
 lbl = new Label
 lbl.Text = Convert.ToString(table.Rows.Item(0).Item("ColumnNameOrIndex"))
Next
 
Junior Spellweaver
Joined
Oct 26, 2007
Messages
108
Reaction score
0
Code:
Not so good in VB but I guess it would be something like this...

for i = 0 to table.Rows.Count
 Dim lbl as Label
 lbl = new Label
 lbl.Text = Convert.ToString(table.Rows.Item(0).Item("ColumnNameOrIndex"))
Next

How would I get this for a specific user though?
 
Junior Spellweaver
Joined
Oct 26, 2007
Messages
108
Reaction score
0
Yes but im looking at getting specific data like it searches user for TheFear then looks for Email on TheFear. This should then replace the text in a label
 
Newbie Spellweaver
Joined
Dec 4, 2009
Messages
73
Reaction score
4
Code:
Not so good in VB but I guess it would be something like this...

for i = 0 to table.Rows.Count
 Dim lbl as Label
 lbl = new Label
 lbl.Text = Convert.ToString(table.Rows.Item(0).Item("ColumnNameOrIndex"))
Next

SELECT * FROM users WHERE user = 'TheFear'

or ...

Code:
SELECT email FROM users WHERE user = 'TheFear'


lbl.Text = Convert.ToString(table.Rows.Item(0).Item("emailField"))
 
Back
Top