Visual Basic.NET - error de enlace

 
Vista:
sin imagen de perfil

error de enlace

Publicado por anonymous (99 intervenciones) el 07/04/2015 22:22:55
Hola Expertos:
tengo este codigo y funciona todo bien solo con el primer boton, apretando el segundo sale el error: "provoca que dos enlaces en la coleccion se enlacen a la misma propiedad". Entiendo que solo hay que cerrar la base de datos o el dataselect o algo así pero no encuentro como hacerle. Agradezco cualquier ayuda. Gracias de antemano.

Imports System.Data
Imports System.Data.OleDb

Public Class frmCiber
Dim maq As String
Private Sub frmCiber_Load(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles MyBase.Load
'conectarse()
End Sub
Public Sub conectarse()
Dim conn As String
conn = "Provider=Microsoft.ACE.OLEDB.12.0;Data Source=|DataDirectory|\ciber.accdb;Persist Security Info=False"
Dim cmd As OleDbConnection
cmd = New OleDbConnection(conn)
Dim tAdapter As OleDbDataAdapter
tAdapter = New OleDbDataAdapter
tAdapter.SelectCommand = New OleDbCommand("select * from maquinas where idpc = '" + maq + "'", cmd)
Dim maqDataSet As DataSet
maqDataSet = New DataSet
maqDataSet.Tables.Add("maquinas")
tAdapter.Fill(maqDataSet.Tables("maquinas"))

lboxnombres.DataSource = maqDataSet.Tables("maquinas")
lboxnombres.DisplayMember = "idpc"

GroupBox2.DataBindings.Add("text", maqDataSet.Tables("maquinas"), "idpc")
Label8.DataBindings.Add("text", maqDataSet.Tables("maquinas"), "horainicio")
cmd.Close() ''' no se si esta instruccion este bien o que es lo que no funciona realmente
End Sub

Private Sub but1_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles but1.Click
maq = "ciber1"
conectarse()
End Sub

Private Sub but2_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles but2.Click
maq = "ciber2"
conectarse()
End Sub
Valora esta pregunta
Me gusta: Está pregunta es útil y esta claraNo me gusta: Está pregunta no esta clara o no es útil
0
Responder