
27/01/2012, 20:57
|
| | Fecha de Ingreso: enero-2012
Mensajes: 1
Antigüedad: 13 años Puntos: 0 | |
Recorrer las filas que obtuve de mi colsulta Que tal amigos, según yo estuve buscando en lo foros respecto a mi problema y no encontré lo que necesitaba, así que abrí este tema espero me puedan ayudar.
Estoy tratando de utilizar los datos de una consulta a mi BD para realizar unas operaciones con ellos para después ingresarlos a mi DataSet, hasta todo bien. . .
El problema es:
Que esas operaciones solo las hace con la primera fila que trae la consulta y necesito que las haga con todas las filas que encuentre en mi consulta.
Mi codigo es bastante largo asi que pegare un poco resumiendo lo que hace:
Dim dt As New DataTable("dtGenerador")
Dim ds As New Data.DataSet("dsGenerador")
oCnn.Open()
comando = New OleDbCommand("Select count (*) from zacate where finiquito = '" & FFiniquito & "'", oCnn)
Dim count As Integer = Convert.ToInt32(comando.ExecuteScalar())
If count = 0 Then
comando = New OleDbCommand("SELECT F.FOLIOFINIQUITO,F.PERMISOFOLIO,
F.LEVANTO,F.ELABORO,F.REVISO,F.IMPORTE,F.FECHAELAB ORACION,F.RETENDIDO,F.ZIPPER,P.PROPIETARIO,P.PPRAN CHO,P.EJIDOLOCALIDAD,P.MUNICIPIO,A.TIPODELINEA,A.N UMERODELINEA,A.ESTACIONI,A.METROS,A.ESTACIONF,A.ME TROSF,A.ANCHO,A.FECHA,R.CULTIVOS,R.TIPO,O.PRECIO FROM TBLFINIQUITOSAMP AS F INNER JOIN TBLPERMISOSAMP AS P ON F.PERMISOFOLIO=P.PERMISOFOLIO INNER JOIN TBLAFECTACION4 AS A ON A.PERMISOFOLIO=F.PERMISOFOLIO INNER JOIN TBLPRECIOS AS R ON R.CLAVE=A.AFECTACION INNER JOIN SYSPERMISIONS AS S ON S.TABULADOR=F.TABULADOR INNER JOIN SYSOBJECTSS AS O ON S.ID_TABULADOR=O.ID_TABULADOR WHERE O.CLAVE_CULTIVO = A.AFECTACION AND A.FECHA = '" & tbFecha.Text & "' AND F.FOLIOFINIQUITO = '" & FFiniquito & "'", oCnn)
linea = comando.ExecuteReader()
While linea.Read()
dr = dt.NewRow()
vEstacaI = linea.GetInt32(15)
vMetros = linea.GetInt32(16)
vEstacaF = linea.GetInt32(17)
vMetrosF = linea.GetInt32(18)
vAncho = linea.GetInt32(19)
vPrecio = linea.GetString(23)
vTipodeLinea = linea.GetString(13)
vZipper = linea.GetInt32(8)
vFecha = linea.GetString(20)
vTipo = linea.GetInt32(22)
vPrecio = linea.GetString(23)
Select Case vZipper
Case 17
dr("SECTOR") = "BLOQUE 4"
dr("CAMPO") = "AREA MIAHUAPAN"
Case Else
End Select
If vTipodeLinea = "LF" Then
vKilometros = ((vEstacaF - vEstacaI) * 50 + (vMetrosF - vMetrosF)) / 1000
vAreaHas = (vKilometros * vAncho) / 10
vCantidad = (vAreaHas * 26000) / (vPrecio * 0.05)
vTotal = vCantidad * 0.05 * vPrecio
End If
If vTipodeLinea = "AO" Then
vKilometros = vMetros / 1000
vAreaHas = (vKilometros * vAncho) / 10
vCantidad = (vAreaHas * 26000) / (vPrecio * 0.05)
vTotal = vCantidad * 0.05 * vPrecio
End If
If vTipodeLinea = "AM" Then
vKilometros = 0
vAreaHas = (((vEstacaF - vEstacaI) + 1) * 8) / 10000
vCantidad = (vAreaHas * 26000) / (vPrecio * 0.05)
vTotal = vCantidad * (0.05 / 100) * vPrecio
vAncho = 8
vPorciento = 0.05
End If
If vTipodeLinea = "LR" Then
vKilometros = ((vEstacaF - vEstacaI) * 50 + (vMetrosF - vMetros)) / 1000
vAreaHas = (vKilometros * vAncho) / 10
vCantidad = (vAreaHas * 26000) / (vPrecio * 0.03)
vTotal = vCantidad * 0.03 * vPrecio
End If
dr("FOLIOFINIQUITO") = linea.GetInt32(0)
dr("PERMISOFOLIO") = linea.GetInt32(1)
dr("LEVANTO") = linea.GetString(2)
dr("ELABORO") = linea.GetString(3)
dr("REVISO") = linea.GetString(4)
dr("IMPORTE") = linea.GetDecimal(5)
dr("FECHAELABORACION") = linea.GetDateTime(6)
dr("PROPIETARIO") = linea.GetString(9)
dr("PPRANCHO") = linea.GetString(10)
dr("EJIDOLOCALIDAD") = linea.GetString(11)
dr("MUNICIPIO") = linea.GetString(12)
dr("NUMERODELINEA") = linea.GetInt32(14)
dr("ESTACIONI") = linea.GetInt32(15)
dr("METROS") = linea.GetInt32(16)
dr("ESTACIONF") = linea.GetInt32(17)
dr("METROSF") = linea.GetInt32(18)
dr("ANCHO") = vAncho
dr("CULTIVOS") = linea.GetString(21)
dr("PRECIO") = vPrecio
dr("CANTIDAD") = vCantidad
dr("PORCENTAJE") = vPorciento
dr("KILOMETROS") = vKilometros
dr("AREAHAS") = vAreaHas
dr("TOTAL") = vTotal
dt.Rows.Add(dr)
End While
linea.Close()
oCnn.Close()
ds.Tables.Add(dt)
Dim report As New crGenerador()
report.SetDataSource(ds)
FGenerador.crvGenerador.ReportSource = report
FGenerador.Show()
Bueno ese es parte de mi codigo que creo resume lo que quiero hacer, todo funciona bien pero solo lo hace con la primera fila de mi consulta y no con todas las que salen, espero puedan ayudarme con mi problema. |