
27/03/2007, 10:26
|
| | Fecha de Ingreso: septiembre-2005 Ubicación: Medellin
Mensajes: 215
Antigüedad: 19 años, 7 meses Puntos: 0 | |
Re: Mostrar consulta SQL en MSFlexGrid o DataGrid ok, yo lo hago de la siguiente forma para el MSFlexGrid.
'Primero declaro el recordset
Set RsRep = New ADODB.Recordset
RsRep.LockType = adLockOptimistic
RsRep.CursorType = adOpenKeyset
RsRep.ActiveConnection = CnGeneral
'Luego hago al consulta y confirmo que no este vacio es decir que si
'haya traido datos
RsRep.Open "SELECT Cod_Rep, Nom_Rep, Des_Rep FROM Reportes"
If RsRep.RecordCount > 0 Then
LlenarFlex
End If
RsRep.Close
'Por ultimo con esta función lleno el MSFlexGrid
Function LlenarFlex()
Dim intFila As Integer
RsRep.Requery
MsfInf.Clear
MsfInf.Rows = 1
RsRep.MoveFirst
With MsfInf
.ColWidth(0) = 800
.ColWidth(1) = 2000
.ColWidth(2) = 6500
.TextMatrix(0, 0) = "Código"
.TextMatrix(0, 1) = "Nombre"
.TextMatrix(0, 2) = "Descripción"
End With
While Not RsRep.EOF
With MsfInf
intFila = MsfInf.Rows
.Rows = intFila + 1
.TextMatrix(intFila, 0) = RsRep!Cod_Rep
.TextMatrix(intFila, 1) = RsRep!Nom_Rep
.TextMatrix(intFila, 2) = RsRep!Des_Rep
RsRep.MoveNext
End With
Wend
End Function |