Talk2Tom11 Posted June 9, 2006 Posted June 9, 2006 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 Quote
kejpa Posted June 12, 2006 Posted June 12, 2006 Maybe MySQL for VB will help you get started. HTH /Kejpa Quote
college_amy Posted June 15, 2006 Posted June 15, 2006 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.. :) Quote
Recommended Posts
Join the conversation
You can post now and register later. If you have an account, sign in now to post with your account.