You are on page 1of 5

Imports System.Data Imports System.Data.

Odbc Public Class frmPrograma Public conexionBD As OdbcConnection Dim SQL As OdbcCommand Private Sub Button2_Click(ByVal sender As System.Object, ByVal e As System.E ventArgs) Handles Button2.Click Me.Close() End Sub Private Sub Button1_Click(ByVal sender As System.Object, ByVal e As System.E ventArgs) Handles Button1.Click conexionBD = New OdbcConnection("Dsn=conexion;server=localhost;uid=root; pwd=12345;database=proyfinal;port=3306") conexionBD.Open() SQL = New OdbcCommand("INSERT INTO programa(Nombre,Descripcion) VALUES ( '" & txtnombreproye.Text & "','" & txtdescripcion.Text & "')") SQL.Connection = conexionBD SQL.ExecuteNonQuery() MsgBox("Los Datos se han registrado correctamente", MsgBoxStyle.Exclamat ion, "Atencion") conexionBD.Close() End Sub End Class

Imports System.Data Imports System.Data.Odbc

Public Class frmconsultaprogramas Public conexionBD As OdbcConnection Dim SQL As OdbcCommand Dim resultadoSQL As OdbcDataReader Private Sub Button1_Click(ByVal sender As System.Object, ByVal e As System.E ventArgs) Handles Button1.Click Try conexionBD = New OdbcConnection("Dsn=conexion;server=localhost;uid=r oot;database=proyfinal;port=3306") conexionBD.Open() Catch ex As OdbcException MsgBox("Error en la conexion.....", ex.Message) End Try SQL = New OdbcCommand("SELECT * FROM programa WHERE idPrograma =" & Text Box1.Text, conexionBD)

resultadoSQL = SQL.ExecuteReader() resultadoSQL.Read() Try txtNombre.Text = resultadoSQL(1) txtDescripcion.Text = resultadoSQL(2) txtNombre.Visible = True txtDescripcion.Visible = True Label1.Visible = True Label3.Visible = True Label6.Visible = True Catch ex As InvalidOperationException MsgBox("Registro no existe.... Verifique") TextBox1.Focus() TextBox1.SelectAll() End Try End Sub End Class

Imports System.Data Imports System.Data.Odbc Public Class frmBajaInvestigador Public conexionBD As OdbcConnection Dim Resultado As String Dim SQL As OdbcCommand Dim resultadoSQL As OdbcDataReader Private Sub Button1_Click(ByVal sender As System.Object, ByVal e As System.E ventArgs) Handles Button1.Click Try conexionBD = New OdbcConnection("Dsn=conexion;server=localhost;uid=r oot;database=proyfinal;port=3306") conexionBD.Open() Catch ex As OdbcException MsgBox("Error en la conexion.....", ex.Message) End Try SQL = New OdbcCommand("SELECT * FROM investigador WHERE idInvestigador=" & txtbuscar.Text, conexionBD) resultadoSQL = SQL.ExecuteReader() resultadoSQL.Read() Try txtnombre.Text = resultadoSQL(1) txtapellidop.Text = resultadoSQL(2) txtapellidom.Text = resultadoSQL(3) comboescuela.Text = resultadoSQL(4) txtcuerpoaca.Text = resultadoSQL(5) txtcalle.Text = resultadoSQL(6) txtnumext.Text = resultadoSQL(7) txtnumint.Text = resultadoSQL(8)

txtCP.Text = resultadoSQL(9) txtcolonia.Text = resultadoSQL(10) Catch ex As InvalidOperationException MsgBox("Registro no existe.... Verifique") txtbuscar.Focus() txtbuscar.SelectAll() End Try End Sub Private Sub Button2_Click(ByVal sender As System.Object, ByVal e As System.E ventArgs) Handles Button2.Click SQL = New OdbcCommand("DELETE FROM investigador WHERE idInvestigador = " & txtbuscar.Text, conexionBD) resultadoSQL = SQL.ExecuteReader() If MsgBox("BAJA REALIZADA, DESEA BORRAR OTRO REGISTRO? ...", MsgBoxStyle .OkCancel, "REGISTRO BORRADO CORRECTAMENTE") = MsgBoxResult.Cancel Then Me.Hide() End If txtbuscar.Text = "" txtnombre.Text = "" txtapellidop.Text = "" txtapellidom.Text = "" comboescuela.Text = "" txtcuerpoaca.Text = "" txtcalle.Text = "" txtnumext.Text = "" txtnumint.Text = "" txtCP.Text = "" txtcolonia.Text = "" End Sub End Class Imports System.Data Imports System.Data.Odbc Public Class frmModificaInvestigador Public conexionBD As OdbcConnection Dim SQL As OdbcCommand Dim resultadoSQL As OdbcDataReader Private Sub Button1_Click(ByVal sender As System.Object, ByVal e As System.E ventArgs) Handles Button1.Click Try conexionBD = New OdbcConnection("Dsn=conexion;server=localhost;uid=r oot;database=proyfinal;port=3306") conexionBD.Open() Catch ex As OdbcException MsgBox("Error en la conexion.....", ex.Message) End Try SQL = New OdbcCommand("SELECT * FROM investigador WHERE idInvestigador=" & txtbuscar.Text, conexionBD) resultadoSQL = SQL.ExecuteReader()

resultadoSQL.Read() Try txtnombre.Text = resultadoSQL(1) txtapellidop.Text = resultadoSQL(2) txtapellidom.Text = resultadoSQL(3) comboescuela.Text = resultadoSQL(4) txtcuerpoaca.Text = resultadoSQL(5) txtcalle.Text = resultadoSQL(6) txtnumext.Text = resultadoSQL(7) txtnumint.Text = resultadoSQL(8) txtCP.Text = resultadoSQL(9) txtcolonia.Text = resultadoSQL(10) txtnombre.Enabled = False txtapellidop.Enabled = False txtapellidom.Enabled = False comboescuela.Enabled = False txtcuerpoaca.Enabled = False txtcalle.Enabled = True txtnumext.Enabled = False txtnumint.Enabled = False txtCP.Enabled = True txtcolonia.Enabled = True Label1.Visible = True Label3.Visible = True Label4.Visible = True Label5.Visible = True Label6.Visible = True Catch ex As InvalidOperationException MsgBox("Registro no existe.... Verifique") txtbuscar.Focus() txtbuscar.SelectAll() End Try End Sub Private Sub Button2_Click(ByVal sender As System.Object, ByVal e As System.E ventArgs) Handles Button2.Click If CheckBox1.Checked = True Then SQL = New OdbcCommand("UPDATE investigador SET Calle='" & txtcalle.T ext & "' WHERE idInvestigador= " & txtbuscar.Text) SQL.Connection = conexionBD SQL.ExecuteNonQuery() End If If CheckBox2.Checked = True Then SQL = New OdbcCommand("UPDATE investigador SET Cp='" & txtCP.Text & "' WHERE idInvestigador= " & txtbuscar.Text) SQL.Connection = conexionBD SQL.ExecuteNonQuery() End If If CheckBox3.Checked = True Then SQL = New OdbcCommand("UPDATE investigador SET Colonia='" & txtcolon ia.Text & "' WHERE idInvestigador= " & txtbuscar.Text) SQL.Connection = conexionBD

SQL.ExecuteNonQuery() End If End Sub End Class Imports System.Data Imports System.Data.Odbc Public Class frmTipopart Public conexionBD As OdbcConnection Dim SQL As OdbcCommand Private Sub Button1_Click(ByVal sender As System.Object, ByVal e As System.E ventArgs) Handles Button1.Click conexionBD = New OdbcConnection("Dsn=conexion;server=localhost;uid=root; pwd=12345;database=proyfinal;port=3306") conexionBD.Open() SQL = New OdbcCommand("INSERT INTO cat_tipo_p(Descripcion) VALUES ('" & ComboBox1.Text & "')") Sql.Connection = conexionBD Sql.ExecuteNonQuery() MsgBox("Los Datos se han registrado correctamente", MsgBoxStyle.Exclamat ion, "Atencion") conexionBD.Close() End Sub End Class

You might also like