les dejo el codigo
Imports MySql.Data.MySqlClient
Public Class proyectos_cartera
Dim cnGen As New MySqlConnection
Dim Primera As Boolean = True
Dim cnUsuario As New MySqlConnection
Sub Conectar()
Dim Departamento As Integer = 0
Dim Municipio As Integer = 0
Dim xPrimera As Boolean = True
Dim strQry As String = ""
Try
If Len(StringCn) > 0 Then
cnGen.ConnectionString = StringCn
cnGen.Open()
End If
Catch ex As Exception
MensajeError(Err.Description)
End Try
If cnGen.State = ConnectionState.Open Then
Try
Catch ex As Exception
MensajeError(Err.Description)
End Try
End If
End Sub
Sub Consulta()
Dim dsGen As New DataSet
Dim daGen As New MySqlDataAdapter
Dim strQry As String
Try
strQry = "SELECT id_gg, denominacion FROM grupo"
daGen.SelectCommand = New MySqlCommand(strQry, cnGen)
daGen.Fill(dsGen, "grupo")
DenominacionComboBox.DataSource = dsGen.Tables("grupo")
DenominacionComboBox.DisplayMember = ("denominacion")
DenominacionComboBox.ValueMember = ("id_gg")
If DenominacionComboBox.SelectedIndex >= -1 Then
DenominacionComboBox.SelectedIndex = 0
End If
Catch ex As Exception
MensajeError(Err.Description)
End Try
End Sub
Private Sub Proyecto_carteraBindingNavigatorSaveItem_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Proyecto_carteraBindingNavigatorSaveItem.Click
Me.Validate()
Me.Proyecto_carteraBindingSource.EndEdit()
Me.Proyecto_carteraTableAdapter.Update(Me.GestorDataSet.proyecto_cartera)
End Sub
Private Sub proyectos_cartera_Load(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles MyBase.Load
'TODO: esta línea de código carga datos en la tabla 'GestorDataSet.proyecto_cartera' Puede moverla o quitarla según sea necesario.
Me.Proyecto_carteraTableAdapter.Fill(Me.GestorDataSet.proyecto_cartera)
Conectar()
Consulta()
End Sub
Private Sub ToolStripButton1_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles ToolStripButton1.Click
menu_principal.Show()
Me.Visible = False
End Sub
Private Sub BindingNavigatorAddNewItem_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles BindingNavigatorAddNewItem.Click
Id_proyectoTextEdit.Enabled = True
DenominacionComboBox.Enabled = True
FechaDateEdit.Enabled = True
ActividadTextBox.Enabled = True
ObjetivoTextBox.Enabled = True
Resultado_esperadoTextBox.Enabled = True
Id_proyectoTextEdit.Focus()
End Sub
Private Sub DenominacionComboBox_SelectedIndexChanged(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles DenominacionComboBox.SelectedIndexChanged
If DenominacionComboBox.Enabled = True Then
Consulta()
Primera = True
End If
End Sub
End Class
Imports MySql.Data.MySqlClient
Public Class proyectos_cartera
Dim cnGen As New MySqlConnection
Dim Primera As Boolean = True
Dim cnUsuario As New MySqlConnection
Sub Conectar()
Dim Departamento As Integer = 0
Dim Municipio As Integer = 0
Dim xPrimera As Boolean = True
Dim strQry As String = ""
Try
If Len(StringCn) > 0 Then
cnGen.ConnectionString = StringCn
cnGen.Open()
End If
Catch ex As Exception
MensajeError(Err.Description)
End Try
If cnGen.State = ConnectionState.Open Then
Try
Catch ex As Exception
MensajeError(Err.Description)
End Try
End If
End Sub
Sub Consulta()
Dim dsGen As New DataSet
Dim daGen As New MySqlDataAdapter
Dim strQry As String
Try
strQry = "SELECT id_gg, denominacion FROM grupo"
daGen.SelectCommand = New MySqlCommand(strQry, cnGen)
daGen.Fill(dsGen, "grupo")
DenominacionComboBox.DataSource = dsGen.Tables("grupo")
DenominacionComboBox.DisplayMember = ("denominacion")
DenominacionComboBox.ValueMember = ("id_gg")
If DenominacionComboBox.SelectedIndex >= -1 Then
DenominacionComboBox.SelectedIndex = 0
End If
Catch ex As Exception
MensajeError(Err.Description)
End Try
End Sub
Private Sub Proyecto_carteraBindingNavigatorSaveItem_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Proyecto_carteraBindingNavigatorSaveItem.Click
Me.Validate()
Me.Proyecto_carteraBindingSource.EndEdit()
Me.Proyecto_carteraTableAdapter.Update(Me.GestorDataSet.proyecto_cartera)
End Sub
Private Sub proyectos_cartera_Load(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles MyBase.Load
'TODO: esta línea de código carga datos en la tabla 'GestorDataSet.proyecto_cartera' Puede moverla o quitarla según sea necesario.
Me.Proyecto_carteraTableAdapter.Fill(Me.GestorDataSet.proyecto_cartera)
Conectar()
Consulta()
End Sub
Private Sub ToolStripButton1_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles ToolStripButton1.Click
menu_principal.Show()
Me.Visible = False
End Sub
Private Sub BindingNavigatorAddNewItem_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles BindingNavigatorAddNewItem.Click
Id_proyectoTextEdit.Enabled = True
DenominacionComboBox.Enabled = True
FechaDateEdit.Enabled = True
ActividadTextBox.Enabled = True
ObjetivoTextBox.Enabled = True
Resultado_esperadoTextBox.Enabled = True
Id_proyectoTextEdit.Focus()
End Sub
Private Sub DenominacionComboBox_SelectedIndexChanged(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles DenominacionComboBox.SelectedIndexChanged
If DenominacionComboBox.Enabled = True Then
Consulta()
Primera = True
End If
End Sub
End Class