Hello , I would like to enquire if how could I put MYSQL Row to a TextBox ?

Here is my code

Private Sub Form1(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles MyBase.Load
        MySqlConnection = New MySqlConnection
        MySqlConnection.ConnectionString = "server=localhost;Port=3306; user id =root; password=****; database=visualbasic"

        Dim Myadapter As New MySqlDataAdapter
        Dim Sqlquery = "Select Sec FROM codes where username = '" & Info.Text & "' AND code = '" & Form5.Code.Text & "';"
        Dim command As New MySqlCommand
        command.Connection = MySqlConnection
        command.CommandText = Sqlquery
        Myadapter.SelectCommand = command
        Dim Mydata As MySqlDataReader
        Mydata = command.ExecuteReader
        If Mydata.HasRows = 1 Then
        End If
The coloured RED part . How can i change it to send the rows values to a Textbox?
Cause my program will close within a seconds specified . and it uses mysql to check if the value of seconds is how much.
If it is still not very detailed, i am willing to tell more.
(Coloured Green [Sec] Equals to Seconds)
    End Sub

Recommended Answers

All 3 Replies


check this :

Dim queryString As String = _
      "Select Sec FROM codes where username = '" & Info.Text _
      & "' AND code = '" & Form5.Code.Text & "';"
Using connection As New SqlConnection(connectionString)
    Dim command As New SqlCommand(queryString, connection)
        Dim reader As SqlDataReader = command.ExecuteReader()
            If  reader.Read() Then
                TextBox1.Text = Reader(0)
            End If
            ' Always call Close when done reading.
        End Try
    End Using

You can check this link


Hey Veena !
Thank you for your reply ! But i am a newbie to coding .. Hmm, i got a error for this command line.

Using connection As New SqlConnection(connectionString)

May i know what's wrong?

OK i got it working ! Thank you !! I love you ! (:

Be a part of the DaniWeb community

We're a friendly, industry-focused community of developers, IT pros, digital marketers, and technology enthusiasts meeting, learning, and sharing knowledge.