Jump to content
Xtreme .Net Talk

Recommended Posts

Posted

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...

 

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

Posted

Since you are using VS2005 - why don't you use the SQL controls in the toolbox. They do all the connections for you and it is a lot easier.

Use the SQL Connection (above the Access one).. it isn't just for SQL Server.

Hope that helps.

Amy

 

OH and it will test the query and connection right there in the wizard.. super easy... saves the hands for coding other things.. :)

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.

Guest
Reply to this topic...

×   Pasted as rich text.   Paste as plain text instead

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

×
×
  • Create New...