|
-
Jun 30th, 2012, 10:55 AM
#1
Thread Starter
New Member
VB2010 and Mysql does not display all data from table fields on my textboxes
I have a MySQL Database (ixdatabase) where I have several tables one of them is "masterlist". I have several textboxes which can display the data from my table BUT not all. It can only display SURNAME,GIVEN,MID, MIDDLE but for the other fields, it can't. I have double checked my database and I'm positive that I am linking my code to the correct one, also there are no whitespaces or special characters. I am quite a newbie on this, I wonder what is wrong with what I am doing?
Code:
Imports MySql.Data.MySqlClient
Public Class frm_masterlist
Dim ServerString As String = "Server=localhost;User Id=root;Password=aaaaaa;Database=ixdatabase"
Dim SQLConnection As MySqlConnection = New MySqlConnection
Dim cmd As MySqlCommand = New MySqlCommand
Dim dadapter As New MySqlDataAdapter
Dim datardr As MySqlDataReader
Dim strsql As String
Private Sub frm_masterlist_Load(sender As Object, e As System.EventArgs) Handles Me.Load
SQLConnection.ConnectionString = ServerString
If SQLConnection.State = ConnectionState.Closed Then
SQLConnection.Open()
MsgBox("Connection to Database is Established")
Else
MsgBox("Cannot establish connection to Database")
End If
strsql = "SELECT * FROM ixdatabase.masterlist ORDER BY SURNAME"
cmd.CommandText = strSql
cmd.Connection = SQLConnection
dadapter.SelectCommand = cmd
datardr = cmd.ExecuteReader
If datardr.HasRows Then
datardr.Read()
tb_lname.Text = datardr("SURNAME")
tb_fname.Text = datardr("GIVEN")
tb_mname.Text = datardr("MID")
tb_mi.Text = datardr("MIDDLE")
tb_app.Text = datardr("APPELLATION")
tb_prefix.Text = datardr("PREFIX")
tb_sex.Text = datardr("SEX")
tb_status.Text = datardr("STATUS")
End If
End Sub
Private Sub cmd_close_Click(sender As System.Object, e As System.EventArgs) Handles cmd_close.Click
Me.Close()
SQLConnection.Close()
End Sub
End Class
Or perharps, you can help me improve my code.. Please help. Thanks!
Tags for this Thread
Posting Permissions
- You may not post new threads
- You may not post replies
- You may not post attachments
- You may not edit your posts
-
Forum Rules
|
Click Here to Expand Forum to Full Width
|