Essays.club - Ensayos gratis, notas de cursos, notas de libros, tareas, monografías y trabajos de investigación
Buscar

Laboratorio de base de datos

Enviado por   •  12 de Noviembre de 2018  •  778 Palabras (4 Páginas)  •  382 Visitas

Página 1 de 4

...

Obj.operaciones(DataGridView2, Sql)

Next

End Sub

Private Sub Button3_Click(sender As Object, e As EventArgs) Handles Button3.Click

For a As Integer = 0 To 11

'Dim Sql As String = "Insert Into Equipo (Jugados, Ganados, Empatados, Perdidos, GA, GC, Puntos) Select " & DataGridView2.Rows(a).Cells(2).Value & ", '" & DataGridView2.Rows(a).Cells(3).Value & "', '" & DataGridView2.Rows(a).Cells(4).Value & "', '" & DataGridView2.Rows(a).Cells(5).Value & "', '" & DataGridView2.Rows(a).Cells(6).Value & "', '" & DataGridView2.Rows(a).Cells(7).Value & "', '" & DataGridView2.Rows(a).Cells(8).Value & "'"

Dim Sql As String = "Update Equipo Set Jugados='" & 0 & "', Ganados='" & 0 & "',Empatados ='" & 0 & "',Perdidos ='" & 0 & "' ,GA ='" & 0 & "',GC ='" & 0 & "' ,Puntos ='" & 0 & "' where Id=" & a + 1 & ""

Obj.operaciones(DataGridView2, Sql)

Next

Me.Close()

End Sub

Private Sub Button4_Click(sender As Object, e As EventArgs) Handles Button4.Click

Me.Hide()

Form2.Show()

End Sub

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

Try

Me.EquipoTableAdapter.FillBy(Me.FutbolDataSet.Equipo)

Catch ex As System.Exception

System.Windows.Forms.MessageBox.Show(ex.Message)

End Try

End Sub

Private Sub Button5_Click(sender As Object, e As EventArgs) Handles Button5.Click

Me.Close()

End Sub

End Class

Clase CRUD

Imports System.Data.OleDb

Public Class CRUD

Dim con As New OleDbConnection("Provider=Microsoft.Jet.OleDb.4.0; Data Source=C:\Users\Luis\Documents\Visual Studio 2015\Projects\Problema1_Proyecto2\Problema1_Proyecto2\Fut.mdb")

Sub conexion()

Try

con.Open()

MsgBox("Conexión realizada de manera exitosa", MsgBoxStyle.Information, "Tutorial CRUD")

con.Close()

Catch ex As Exception

MsgBox("No se logro realizar la conexión debido: ")

End Try

End Sub

Sub consulta(ByVal Tabla As DataGridView, ByVal Sql As String)

Try

Dim DA As New OleDbDataAdapter(Sql, con)

Dim DT As New DataTable

DA.Fill(DT)

Tabla.DataSource = DT

Catch ex As Exception

MsgBox("No se logro realizar la consulta por: ")

End Try

End Sub

Sub operaciones(ByVal Tabla As DataGridView, ByVal Sql As String)

con.Open()

Try

Dim cmd As New OleDbCommand(Sql, con)

cmd.ExecuteNonQuery()

Catch ex As Exception

MsgBox("No se logro realizar la operación por ")

End Try

con.Close()

End Sub

End Class

Form 2

Imports System.ComponentModel

Public Class Form2

Dim Obj As New CRUD

Private Sub Form2_Load(sender As Object, e As EventArgs) Handles MyBase.Load

Obj.conexion()

Dim Sql As String = "Select * from Equipo"

Obj.consulta(DataGridView1, Sql)

DataGridView1.Sort(DataGridView1.Columns(8), ListSortDirection.Descending)

Label2.Text = DataGridView1.Rows(0).Cells(1).Value

For a As Integer = 0 To 11

DataGridView1.Rows(a).Cells(0).Value = a + 1

Next

End Sub

Private Sub Button1_Click(sender As Object, e As EventArgs) Handles Button1.Click

Me.Close()

Form1.Close()

End Sub

End Class

- Resumen

Dentro del Programa se implementó el tab control, data adapter, el data set , igual se usó el manejo de datos dentro de visual, los controles datagridview y llamado de clases.

El

...

Descargar como  txt (7.2 Kb)   pdf (55.8 Kb)   docx (16.9 Kb)  
Leer 3 páginas más »
Disponible sólo en Essays.club