0% found this document useful (0 votes)
16 views4 pages

Video de Tarea Programacion 4

This document contains code for a 3-form login system in Visual Basic that connects to a MySQL database. Form1 contains a login screen that verifies a username and password. Form2 prompts for database connection details. Form3 connects to the database and closes upon a successful connection. The code demonstrates connecting a Visual Basic application to a MySQL database by prompting for login credentials and connection details across multiple forms.
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as DOCX, PDF, TXT or read online on Scribd
0% found this document useful (0 votes)
16 views4 pages

Video de Tarea Programacion 4

This document contains code for a 3-form login system in Visual Basic that connects to a MySQL database. Form1 contains a login screen that verifies a username and password. Form2 prompts for database connection details. Form3 connects to the database and closes upon a successful connection. The code demonstrates connecting a Visual Basic application to a MySQL database by prompting for login credentials and connection details across multiple forms.
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as DOCX, PDF, TXT or read online on Scribd
You are on page 1/ 4

Universidad Cristiana Evangélica Nuevo

Milenio.

Ejercicio Practico N3

Victor Josué Rodriguez Chávez

Catedrático: Erick Ricardo Chirinos Muñoz

Asignatura: Programacion IV

Lugar: Pena Blanca Cortes

Fecha de entrega: 12 Febrero del 2022

Valor del trabajo.3 %


VIDEO DE TAREA PROGRAMACION 4
https://drive.google.com/file/d/
165SZmPJx47RudH41UzQ7idF5qPQAB0i-/view?usp=sharing

Public Class Form1


Private Sub Button1_Click(sender As Object, e As EventArgs)
Handles Button1.Click
Dim usuario As String
Dim contrasena As Integer
usuario = TextBox1.Text
contrasena = TextBox2.Text
If (usuario = "admin") And (contrasena = "1234") Then

Form2.Show()

Else
MsgBox("Usuario o Contrasena incorrecta")
Me.Close()
End If
End Sub
End Class

1
Public Class Form2
Private Sub Form2_Load(sender As Object, e As EventArgs)
Handles MyBase.Load

End Sub

Private Sub Button1_Click(sender As Object, e As EventArgs)


Handles Button1.Click
Dim base, usua, contra, servi As String
servi = TextBox1.Text
usua = TextBox2.Text
contra = TextBox3.Text
base = TextBox4.Text
If (servi = "localhost") And (usua = "josue2022") And
(contra = "99564854") And (base = "tareatres") Then
Form3.Show()

Else
MsgBox("Datos Incorrectos")
Me.Close()
End If
End Sub
End Class

2
CONEXION A BASE DE DATOS
Imports MySql.Data.MySqlClient
Public Class Form3
Private Sub Form3_Load(sender As Object, e As EventArgs) Handles
MyBase.Load
Try
Dim Conexion As New MySqlConnectionStringBuilder
Conexion.Server = "localhost" ' Servidor de mi base de
datos

Conexion.UserID = "josue2022" 'Id o nombre usuario

Conexion.Password = "99564854" ' Pasword del usuario de la


base de datos
Conexion.Database = "tareatres" ' Nombre de nuestra base
de datos

Dim con As New MySqlConnection(Conexion.ToString)


con.Open()
MsgBox("Conexion Exitosa")
Me.Close()

Catch ex As Exception
MsgBox("Conexion Fallida " & ex.Message)
Me.Close()
End Try
End Sub
End Class

You might also like