Hey guys, ive bin following someones tutorials on how to connect and view data in a sql databse table.
Does anyone know how to send data from say two textboxes to the table, say Name and Gender

Heres the working code I have at the moment.

Imports MySql.Data.MySqlClient
Module SQL
    Dim Send As New MySqlCommand
    Dim Command As New MySqlCommand
    Dim Connection As New MySqlConnection("server=" & Form1.txtServer.Text & ";user id=" & Form1.txtUsername.Text & "; password=" & Form1.txtPassword.Text & "; port=3306; database=" & Form1.txtdb.Text & "; pooling=false")

    Public Sub Connect()
        Try
            Connection.Open()
            MsgBox("Connected to: " & Form1.txtServer.Text)
            Form3.Show()
        Catch ex As MySqlException
            MsgBox(ex.Message)
        End Try
    End Sub

    Public Sub GetData(ByRef Table As String, ByRef output As DataTable)
        Try
            Command = New MySqlCommand("SELECT * FROM `" & Table & "` LIMIT 100;", Connection)
            Dim MySqlA As New MySqlDataAdapter(Command)
            MySqlA.Fill(output)
            If output.Rows.Count = 0 Then
                output = Nothing
            End If
        Catch e As MySqlException
            MsgBox(e.Message)
        End Try
    End Sub
  
End Module

Thanks

Recommended Answers

All 3 Replies

You need to explain more by what you mean "send to the database". Do you want to use them in a query, store them in a table, use them to login?

Just add the data to the table.

So I have 2 fields Name and Gender.
Text I put into textbox1 gets added to a new row under the Name field and text input into textbox2 gets put into the row under the gender field.

bump

Be a part of the DaniWeb community

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