Está en la página 1de 2

CONECTAR MYSQL CON VB.

NET
Imports MySql.Data.MySqlClient
Try
conexion.ConnectionString = ("Data Source=localhost;
Database=zuiga;Uid=root;Password=aiep")
Catch ex As MySqlException
MessageBox.Show("No se ha podido conectar al servidor")
End Try

AUTENTIFICACION DE USUARIO
Imports MySql.Data.MySqlClient
miconsulta("select * from where usuario='" & (txtusuario.Text) & "' and clave='"
&txtcontrasea.Text) & "'")
If DS.Tables(DT.TableName).Rows.Count > 0 Then
inicio.Show()
Me.Hide()
Else
My.Computer.Audio.Play(My.Resources.DETENTE, AudioPlayMode.Background)SONIDO DE ERROR
MsgBox("ERROR AL INGRESAR DATOS")
End If

REDIMENSIONAR FORMULARIO POR BOTON


If Button2.Text = "v" Then
Button2.Text = "^"
Me.Size = New System.Drawing.Size(504, 284)
ElseIf Button2.Text = "^" Then
Button2.Text = "v"
Me.Size = New System.Drawing.Size(504, 206)
End If

MOVER FORMULARIO SIN BORDES


Friend/Dim ex, ey As Integer
Friend/Dim Arrastre As Boolean --DEFINICION DE VARIABLES(Friend si son varios form y
poner en un mdulo)
Private Sub Form1_MouseDown CODIGO SEGUN PROCESO DE FORMULARIO
ex = e.X
ey = e.Y
Arrastre = True
End Sub
Private Sub Form1_MouseMove
If Arrastre Then Me.Location = Me.PointToScreen(New Point(Me.MousePosition.X Me.Location.X - ex,
Me.MousePosition.Y - Me.Location.Y - ey))
End Sub

Private Sub Form1_MouseUp


Arrastre = False
End Sub

CODIGO CONEXION Y CONSULTAS EN MODULO


Module Module1
Friend conexion As New MySqlConnection
Friend
Friend
Friend
Friend

SC As New MySqlCommand
DA As New MySqlDataAdapter
DS As New DataSet()
DT As New DataTable

Sub miconsulta(varsql As String)


DS.Tables.Clear()
DT.Rows.Clear()
DT.Columns.Clear()
DS.Clear()
conexion.Close()
conexion.Open()
SC.Connection = conexion
SC.CommandText = varsql
DA.SelectCommand = SC
DA.Fill(DT)
DS.Tables.Add(DT)
conexion.Close()
End Sub

REPETIR SI ES NECESARIO

También podría gustarte