Académique Documents
Professionnel Documents
Culture Documents
Iniciar de inmediato la descarga, este instalador ser compatible para Windows 7, W8, W8.1,
Y W10, si desea realizar una descarga para versiones de WINDOWS XP visite el siguiente link
https://sourceforge.net/projects/xampp/files/XAMPP%20Windows/1.8.2/
1
VISUAL BASIC .NET & MYSQL
DESPUES DE FINALIZAR LA INSTALACION ABRIREMOS XAMMP Y APERTURAMOS TODOS LOS
SERVICIOS
CREAREMOS UNA RUTINA QUE PERMITA ALMACENAR DATOS DE UN USUARIO EN UNA BASE
DE DATOS DE MYSQL.
2
VISUAL BASIC .NET & MYSQL
Y LUEGO EN DESCARGAR
3
VISUAL BASIC .NET & MYSQL
4
VISUAL BASIC .NET & MYSQL
5
VISUAL BASIC .NET & MYSQL
Nuevamente iremos a examinar pero en la parte inferior del explorador
Click agregar, click aceptar y listo hemos agregado la referencia para trabajar
con cdigos MYSQL
6
VISUAL BASIC .NET & MYSQL
Escribiremos el cdigo adaptndolo a la realidad de nuestra bd.
Imports MySql.Data.MySqlClient
Public Class Form1
Public con As New MySqlConnection("server=localhost;Database=dbsist; User
id=root;Password=;")
Private Sub Button1_Click(sender As Object, e As EventArgs) Handles
Button1.Click
If TextBox1.Text = "" Then
MsgBox("NO SE PERMITEN ESPACIOS VACIOS")
Else
Dim cmd As New MySqlCommand
Dim r As Integer
Try
con.Open()
cmd = New MySqlCommand("insert into usuarios values ('" &
TextBox1.Text & "','" & TextBox2.Text & "', '" & TextBox3.Text & "','" &
TextBox4.Text & "','" & TextBox5.Text & "','" & TextBox6.Text & "')", con)
r = cmd.ExecuteNonQuery()
If r > 0 Then
MsgBox("registrado correctamente")
End If
TextBox1.Text = ""
TextBox2.Text = ""
TextBox3.Text = ""
TextBox4.Text = ""
TextBox5.Text = ""
TextBox6.Text = ""
TextBox1.Enabled = False
TextBox2.Enabled = False
TextBox3.Enabled = False
TextBox4.Enabled = False
TextBox5.Enabled = False
TextBox6.Enabled = False
Catch ex As Exception
MsgBox(ex.Message)
End Try
con.Close()
End If
End Sub
Private Sub Button2_Click(sender As Object, e As EventArgs)
frmprincipal.Show()
End Sub
Private Sub Button3_Click(sender As Object, e As EventArgs) Handles
Button3.Click
TextBox1.Text = ""
TextBox2.Text = ""
TextBox3.Text = ""
TextBox4.Text = ""
TextBox5.Text = ""
TextBox6.Text = ""
TextBox1.Enabled = True
TextBox2.Enabled = True
TextBox3.Enabled = True
TextBox4.Enabled = True
TextBox5.Enabled = True
TextBox6.Enabled = True
End Sub
Private Sub Button4_Click(sender As Object, e As EventArgs) Handles
Button4.Click
Close()
End Sub
End Class
7
VISUAL BASIC .NET & MYSQL
Imports MySql.Data.MySqlClient
Public Class frmprincipal
Private Sub Button1_Click(sender As Object, e As EventArgs) Handles
Button1.Click
If (existeusuario(txtusuario.Text, txtpassword.Text)) Then
Me.Hide()
principal.Show()
End If
End Sub
Function existeusuario(ByVal usuario As String, ByVal password As String) As
Boolean
Dim conexion As New MySqlConnection
Dim dataadapter As New MySqlDataAdapter
Dim dataset As New DataSet
Dim sql As String
Dim sw As Boolean = False
Try
conexion.ConnectionString = "server=localhost;Database=dbsist; User
id=root;Password=;"
sql = "select * from usuarios where user='" & usuario & "' and pass=
'" & password & "' "
dataadapter = New MySqlDataAdapter(sql, conexion)
conexion.Open()
dataset.Clear()
dataadapter.Fill(dataset, "usuarios")
If dataset.Tables("usuarios").Rows.Count() <> 0 Then
MessageBox.Show("bienvenido al sistema", "sistema")
sw = True
Else
MessageBox.Show("usuario desconocido", "sistema")
sw = False
End If
Catch ex As Exception
End Try
8
VISUAL BASIC .NET & MYSQL
Return (sw)
End Function
End Class