Talk2Tom11
Well-known member
Hey i am using Visual Basic 2005 and a MySQL database.
I am able to connect to my database but i am alittle unsure about retrieving the information and displaying it in something like a txtbox.
What i want to do for example would be something like this...
SELECT Name FROM test WHERE Id = "1234";
and then have that name display in something like textbox1
this is my code so far...
[VB]Imports MySql.Data.MySqlClient
Public Class frmLogin
Dim conn As MySqlConnection
Private Sub cmdLogin_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles cmdLogin.Click
conn = New MySqlConnection()
conn.ConnectionString = "Server=" & txtServer.Text & ";" _
& "Uid=" & txtUsername.Text & ";" _
& "Pwd=" & txtPassword.Text & ";" _
& "Database=test"
Try
conn.Open()
MessageBox.Show("Connection Opened Successfully")
conn.Close()
Catch myerror As MySqlException
MessageBox.Show("Error Connecting to Database: " & myerror.Message)
Finally
conn.Dispose()
End Try
End Sub[/VB]
I am able to connect to my database but i am alittle unsure about retrieving the information and displaying it in something like a txtbox.
What i want to do for example would be something like this...
SELECT Name FROM test WHERE Id = "1234";
and then have that name display in something like textbox1
this is my code so far...
[VB]Imports MySql.Data.MySqlClient
Public Class frmLogin
Dim conn As MySqlConnection
Private Sub cmdLogin_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles cmdLogin.Click
conn = New MySqlConnection()
conn.ConnectionString = "Server=" & txtServer.Text & ";" _
& "Uid=" & txtUsername.Text & ";" _
& "Pwd=" & txtPassword.Text & ";" _
& "Database=test"
Try
conn.Open()
MessageBox.Show("Connection Opened Successfully")
conn.Close()
Catch myerror As MySqlException
MessageBox.Show("Error Connecting to Database: " & myerror.Message)
Finally
conn.Dispose()
End Try
End Sub[/VB]