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