From: | Hazel Muñoz <hamucacr(at)gmail(dot)com> |
---|---|
To: | "Andres Gutierrez" <adivisi(at)gmail(dot)com> |
Cc: | pgsql-es-ayuda(at)postgresql(dot)org |
Subject: | Re: datagrid de VB 6.0 |
Date: | 2006-04-18 16:42:05 |
Message-ID: | 412fad9f0604180942t17304a62m92175c76bc593c10@mail.gmail.com |
Views: | Raw Message | Whole Thread | Download mbox | Resend email |
Thread: | |
Lists: | pgsql-es-ayuda |
Estoy utilizando un código que encontré en internet, en lugar de usar un
datagrid normal utiliza un MSHFlexGrid, como no he podido hacerlo funcionar
no sé cuál es la diferencia entre ambos.
Aquí va el Sub Load() del Form que tiene el datagrid, no funciona el
RecordCount porque siempre me devuelve -1. ¿Cómo puedo llenar un datagrid,
aunque sea uno de los normales?
Private Sub Form_Load()
SQL = "Select * from responsable"
Set cnUsuario = New ADODB.Connection
cnUsuario.ConnectionString = "DRIVER=PostGreSQL;
Server=localhost;Port=5432;User
Id=postgres;Password=tulipazules;Database=SORA;"
cnUsuario.Open
Option1.Value = True
Set rsResponsable = New ADODB.Recordset
rsResponsable.Open SQL, cnUsuario, adOpenDynamic, adLockOptimistic
Dim i, j
'tell the grid how many columns to have
MSHFlexGrid1.Cols = rsResponsable.Fields.Count
'tell the grid how many rows to have + 1
MSHFlexGrid1.Rows = rsResponsable.RecordCount + 1
j = 0
With rsResponsable
'this loop only fills up the grid captions along the top with the
field "name" not the value
MsgBox rsResponsable.RecordCount, "Error"
Do While j < .Fields.Count + 1
If Not IsNull(.Fields(j).Name) Then
MSHFlexGrid1.TextMatrix(i, j) = .Fields(j).Name
MSHFlexGrid1.TextMatrix(0, 0) = .Fields(j).Name
End If
j = j + 1
Loop
End With
'With rsResponsable
'move to the first record
.MoveFirst
i = 1
Do While i <= .RecordCount
j = 0
'this loop now fills up the grid with the field "value"
Do While j < .Fields.Count
If Not IsNull(.Fields(j).Value) Then
MSHFlexGrid1.TextMatrix(i, j) = .Fields(j).Value
End If
j = j + 1
Loop
.MoveNext 'move to the next record
i = i + 1
Loop
End With
End Sub
--
Hazel MC
From | Date | Subject | |
---|---|---|---|
Next Message | Ivan Figueroa | 2006-04-18 16:46:54 | Re: datagrid de VB 6.0 |
Previous Message | Andres Gutierrez | 2006-04-18 16:33:07 | Re: datagrid de VB 6.0 |