Visual Basic - QUISIERA SABER DE QUE MANERA PODRIA RELIZAR CONSULTAS EN UNA LISTBOX E IMPRIMIRLAS

Life is soft - evento anual de software empresarial
 
Vista:
sin imagen de perfil

QUISIERA SABER DE QUE MANERA PODRIA RELIZAR CONSULTAS EN UNA LISTBOX E IMPRIMIRLAS

Publicado por JHON (2 intervenciones) el 01/06/2017 01:56:11
ME GUSTARIA SABER LA FORMA EN QUE PUEDA REALIZAR UN PROGRAMA QUE REALICE LA MISMA FUNCION QUE EL ARCHIVO ABJUNTO
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
Imágen de perfil de Hebert

QUISIERA SABER DE QUE MANERA PODRIA RELIZAR CONSULTAS EN UNA LISTBOX E IMPRIMIRLAS

Publicado por Hebert (2 intervenciones) el 21/06/2017 19:03:04
Hola amigo que tal...Para realizar una consulta tendras que tener un almacen de datos o Boveda de almaceamiento de datos... Tu Tabla en ese Caso en VB tu ListBox tiene que estar conectado..a tu base de datos seria en SQL SERVER

Antes que nada tienes que Agregar la siguiente referencia al tu proyecto o Trabajo:
Microsoft ActiveX Data Objects 2.5 Library

Agregar 2 controles; 1 Label, 1 ListBox El Label es donde puedes ingresar...tu Consultaa...

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
'Se declara estas variables. ;)
Dim CnN As ADODB.Connection
Dim RsT As ADODB.Recordset
'''''''''''''''''''''''''''''''''''''''''''
 
Dim BD As String
Dim CuentaRegs As Integer
 
 
 
Private Sub Form_Load()
    AbreConexion 'SUB PARA ABRIR LA CONEXIÓN
 
    Set RsT = New ADODB.Recordset 'SE ESTABLECE EL REGISTROS
 
    With RsT 'SE ABRE ELREGISTROS
        .CursorLocation = adUseClient
        .CursorType = adOpenStatic
        .LockType = adLockReadOnly
        .Open "SELECT nombre FROM datos ORDER BY nombre", CnN
    End With
 
    For CuentaRegs = 1 To RsT.RecordCount
        List1.AddItem RsT.Fields("nombre") 'SE AGREGA UNO POR UNO EL DATO DEL CAMPO NOMBRE
 
        RsT.MoveNext 'SE AVANZA UNO ADELANTE
    Next
 
    RsT.Close 'SE CIERRA EL REGISTROS
    Set RsT = Nothing 'Y SE DEJA EN NADA
End Sub
 
Private Sub Form_Unload(Cancel As Integer)
    CnN.Close 'SE CIERRA LA CONEXIÓN AL SALIR
    Set CnN = Nothing 'SE ESTABLECE 
End Sub
 
Private Sub List1_Click()
    Set RsT = New ADODB.Recordset
 
    With RsT 'abre el registro y empieza la consulta
        .CursorLocation = adUseClient
        .CursorType = adOpenStatic
        .LockType = adLockReadOnly
        .Open "SELECT dato1 FROM datos WHERE nombre=" & _
            Chr(39) & List1.Text & Chr(39), CnN
    End With
 
    Label1.Caption = RsT.Fields("dato1") 'EL CAMPO DATO1 EN EL LABEL
 
    RsT.Close 'SE CIERRA
    Set RsT = Nothing 'se reconoce 
End Sub
 
Sub AbreConexion()
    BD = App.Path & "\" & "Almaceamiento.mdb" 'RUTA BASE DE DATOS 
 
    Set CnN = New ADODB.Connection 'SE ESTABLECE UNA CONEXIÓN
 
    With CnN
        .CursorLocation = adUseClient
        .Open "PROVIDER=Microsoft.Jet.OLEDB.4.0;Data Source=" & BD
    End With
End Sub



Espero te sirva cualquier cosa...me conctactas un Saludo desde Peru....
Valora esta respuesta
Me gusta: Está respuesta es útil y esta claraNo me gusta: Está respuesta no esta clara o no es útil
2
Comentar
sin imagen de perfil

QUISIERA SABER DE QUE MANERA PODRIA RELIZAR CONSULTAS EN UNA LISTBOX E IMPRIMIRLAS

Publicado por JHON (2 intervenciones) el 23/06/2017 05:42:01
Gracias por la ayuda ,me sirvio de mucho :D
Valora esta respuesta
Me gusta: Está respuesta es útil y esta claraNo me gusta: Está respuesta no esta clara o no es útil
0
Comentar