Insertar Mostrar Modificar Actualizar

Download as docx, pdf, or txt
Download as docx, pdf, or txt
You are on page 1of 2

Imports

Imports
Imports
Imports

MySql.Data.MySqlClient
System.Data
MySql.Data
System.Windows.Forms.Control

Public Class Form1


Dim comandosql, cmsq As New MySqlCommand
Public mysql_conexion_string As String =
"server=10.68.239.21;database=bdsigsm;uid=root;pwd=toor;"
Dim bdcon As New MySqlConnection(mysql_conexion_string)
Private Sub paneles(ByVal visibilidad As Boolean)
For Each c As Control In Me.Controls
If TypeOf c Is Panel Then
c.Visible = visibilidad
End If
Next
End Sub
Private Sub form1_load(ByVal sender As System.Object, ByVal e As System.EventArgs)
Handles MyBase.Load
paneles(False)
End Sub
Private Sub Button2_Click(sender As System.Object, e As System.EventArgs) Handles
Button2.Click
bdcon.Open()
Dim DA = New MySqlDataAdapter("select * from prueba", bdcon)
Dim dt As New DataTable
DA.Fill(dt)
Me.DataGridView1.Visible = True
paneles()
DataGridView1.DataSource = dt
If bdcon.State = ConnectionState.Open Then bdcon.Close()
End Sub
Private Sub Button1_Click(sender As System.Object, e As System.EventArgs) Handles
Button1.Click
If Me.TextBox1.Text = "" Or Not IsNumeric(TextBox1.Text) Then
MsgBox("Numero esta vacia o el valor no es Entero", MsgBoxStyle.Critical, "Armando
Peralta")

ElseIf TextBox2.Text = "" Then


MsgBox("Nombre esta vacio", MsgBoxStyle.Critical, "Alerta")
Else
bdcon.Open()
comandosql = New MySqlCommand("INSERT INTO prueba (campo1,campo2) values
(" + TextBox1.Text + ",'" + TextBox2.Text + "')", bdcon)
comandosql.ExecuteNonQuery()
MsgBox("Proceso OK", MsgBoxStyle.Information, "Insertar Registros")
If bdcon.State = ConnectionState.Open Then bdcon.Close()
Me.TextBox1.Text = Nothing
Me.TextBox2.Text = Nothing

End If
End Sub

End Class

You might also like