Imports MySql.Data.MySqlClient Imports System.Data Public Class

Anuncio
Imports MySql.Data.MySqlClient
Imports System.Data
Public Class Form1
'Private cmCustomers As CurrencyManager
Dim cadena As String = "Server=instancia sql"
Dim dAdap As New SqlClient.SqlDataAdapter("select * from proveedor", cadena)
Dim con As New MySqlConnection()
Dim da As New MySqlDataAdapter()
Dim ds As New DataSet()
Dim dr As DataRow
Private Sub Form1_Load(ByVal sender As System.Object, ByVal e As System.EventArgs)
Handles MyBase.Load
MySqlDataAdapter1.SelectCommand.CommandText = "select * from proveedor"
MySqlConnection1.Open()
MySqlDataAdapter1.Fill(DataSet1)
MySqlConnection1.Close()
Dim array
For Each array In DataSet1.Tables(0).Rows
TextBox6.Text = array("IDPROV").ToString
TextBox1.Text = array("CODPROV").ToString
TextBox2.Text = array("PROVEEDOR").ToString
TextBox3.Text = array("DIRECCION").ToString
TextBox4.Text = array("TELEFONO").ToString
TextBox5.Text = array("CONTACTO").ToString
Next
End Sub
Private Sub Button1_Click(ByVal sender As System.Object, ByVal e As System.EventArgs)
Handles Button1.Click
MySqlDataAdapter1.SelectCommand.CommandText = "select * from proveedor where
IDPROV='" & TextBox6.Text & "'"
MySqlConnection1.Open()
Dim leer As MySql.Data.MySqlClient.MySqlDataReader
leer = MySqlCommand1.ExecuteReader
leer.Read()
Try
If TextBox6.Text = leer("IDPROV") Then
TextBox1.Text = leer("CODPROV")
TextBox2.Text = leer("PROVEEDOR")
TextBox3.Text = leer("DIRECCION")
TextBox4.Text = leer("TELEFONO")
TextBox5.Text = leer("CONTACTO")
End If
Catch ex As Exception
MsgBox("No existe", MsgBoxStyle.Information, "Confirmar")
End Try
MySqlConnection1.Close()
End Sub
Private Sub Button2_Click(ByVal sender As System.Object, ByVal e As System.EventArgs)
Handles Button2.Click
TextBox1.Text = ""
TextBox2.Text = ""
TextBox3.Text = ""
TextBox4.Text = ""
TextBox5.Text = ""
TextBox6.Text = ""
End Sub
Private Sub Button3_Click(ByVal sender As System.Object, ByVal e As System.EventArgs)
Handles Button3.Click
Dim a, b, c, d, g, f
a = TextBox6.Text
b = TextBox1.Text
c = TextBox2.Text
d = TextBox3.Text
g = TextBox4.Text
f = TextBox5.Text
MySqlConnection1.Open()
MySqlDataAdapter1.SelectCommand.CommandText = "insert into proveedor values('" + a
+ "','" + b + "','" + c + "','" + d + "','" + g + "','" + f + "')"
MySqlDataAdapter1.Fill(DataSet1)
MySqlConnection1.Close()
MsgBox("los registro han sido guardados")
End Sub
Private Sub Button4_Click(ByVal sender As System.Object, ByVal e As System.EventArgs)
Handles Button4.Click
Dim a, b, c, d, g, f
a = TextBox6.Text
b = TextBox1.Text
c = TextBox2.Text
d = TextBox3.Text
g = TextBox4.Text
f = TextBox5.Text
MySqlDataAdapter1.SelectCommand.CommandText
=
"update
proveedor
set
CODPROV='" + b + "',PROVEEDOR='" + c + "',DIRECCION='" + d + "',TELEFONO='" + g +
"',CONTACTO='" + f + "' where IDPROV='" + a + "'"
MySqlDataAdapter1.Fill(DataSet1)
MsgBox("los registro han sido actualizados")
End Sub
Private Sub Button5_Click(ByVal sender As System.Object, ByVal e As System.EventArgs)
Handles Button5.Click
Dim el, a
a = TextBox6.Text
el = MsgBox("desea elimnar", MsgBoxStyle.Critical + MsgBoxStyle.OkCancel, "eliminar")
If el = vbOK Then
MySqlDataAdapter1.SelectCommand.CommandText = "delete from proveedor where
IDPROV='" + a + "'"
MySqlConnection1.Open()
MySqlDataAdapter1.Fill(DataSet1)
MySqlConnection1.Close()
MsgBox("los registro han sido ELIMINADOS")
End If
End Sub
End Class
Descargar