do while loop slaat regel over

Status
Niet open voor verdere reacties.

kees1955

Gebruiker
Lid geworden
30 jul 2017
Berichten
77
ik maak een docoment in pdfsharp
lees daar bij een mysql bestand uit met do while loop
alleen als ik een de lus van do while loop een nieuwe pagina aan maak verliest of slaat hij een regel over
dus bijvoorbeeld op het laatste blad print hij regel 40
maak nieuwe pagina aan
eerste regel op nieuwe blad is regel 42
regel 41 is verdwenen
Wat doe ik verkeerd

Dim pdf As PdfDocument = New PdfDocument
Dim pdfPage As PdfPage = pdf.AddPage
Dim graph As XGraphics = XGraphics.FromPdfPage(pdfPage)
Dim font As XFont = New XFont("courier new", 11, XFontStyle.Regular)
Dim aantal_regels As Integer = 29
Dim regel_teller As Integer = 0
Dim regel_afstand As Integer = 13
Dim pagina_teller As Integer = 1
Dim nieuwe_pagina As Boolean = True
Dim pakbonnummer As String = "10005"


Welke_datum = "2020"
Connectie_Controle()
SQLvraag = "SELECT * " & _
" FROM " & DB & "_" & Welke_datum & ".faktuurinfo " & _
" WHERE pakbonID = " & pakbonnummer

MySqlCommand = New MySqlCommand(SQLvraag, conn)
myData = MySqlCommand.ExecuteReader
myData.Read()

Dim bezorg_Naam As String = Trim(myData("naam"))
Dim bezorg_Adres As String = Trim(myData("adres")) & " " & Trim(myData("huisnummer")) & " " & Trim(myData("huisnummer_toevoeging"))
Dim bezorg_Adres2 As String = Trim(myData("2e_adres"))
Dim bezorg_Postcode_Plaats As String = Trim(myData("postcode")) & Trim(myData("postcode_toevoeging")) & " " & Trim(myData("plaats"))
Dim bezorg_Land As String = Trim(myData("land"))
Dim Klanten_nummer As String = Trim(myData("klantID"))

''pdf.Info.Title = "My First PDF" ''????????????????????

Connectie_Controle()
''##################################### faktuur artikelen ophalen ##########################

SQLvraag = "SELECT * FROM " & DB & "_" & Welke_datum & ".faktuur " & _
" WHERE faktuurnummer = '" & pakbonnummer & "' ORDER BY artikelnummer,besteld"
MySqlCommand = New MySqlCommand(SQLvraag, conn)
myData = MySqlCommand.ExecuteReader

Do While myData.Read()

If nieuwe_pagina = True Then
'#################### afbeelding logo brief plaatsen + onderkant #######################
strBestand = LocatieFotos & "\brief_96dpi.jpg"
graph.DrawImage(System.Drawing.Bitmap.FromFile(strBestand), 0, 0, 575, 110)

''##################### onderkant pakbon
font = New XFont("courier new", Adres_Betaling1_Lettergrootte, XFontStyle.Bold)

graph.DrawString(Adres_Betaling_Gegevens1, font, XBrushes.Black, _
New XRect(0, 395 + (regel_teller * regel_afstand), pdfPage.Width, pdfPage.Height), XStringFormats.Center)
graph.DrawString(Adres_Betaling_Gegevens2, font, XBrushes.Black, _
New XRect(0, 405 + (regel_teller * regel_afstand), pdfPage.Width, pdfPage.Height), XStringFormats.Center)



''################## adres
font = New XFont("courier new", 11, XFontStyle.Regular)
If bezorg_Adres2 = "" Or bezorg_Adres2 = "0" Then
graph.DrawString(bezorg_Naam, font, XBrushes.Black, _
New XRect(350, 175 + (0 * regel_afstand), pdfPage.Width, pdfPage.Height), XStringFormats.TopLeft)

graph.DrawString(bezorg_Adres, font, XBrushes.Black, _
New XRect(350, 175 + (1 * regel_afstand), pdfPage.Width, pdfPage.Height), XStringFormats.TopLeft)


graph.DrawString(bezorg_Postcode_Plaats, font, XBrushes.Black, _
New XRect(350, 175 + (2 * regel_afstand), pdfPage.Width, pdfPage.Height), XStringFormats.TopLeft)

graph.DrawString(bezorg_Land, font, XBrushes.Black, _
New XRect(350, 175 + (3 * regel_afstand), pdfPage.Width, pdfPage.Height), XStringFormats.TopLeft)
Else
graph.DrawString(bezorg_Naam, font, XBrushes.Black, _
New XRect(350, 175 + (0 * regel_afstand), pdfPage.Width, pdfPage.Height), XStringFormats.TopLeft)

graph.DrawString(bezorg_Adres, font, XBrushes.Black, _
New XRect(350, 175 + (1 * regel_afstand), pdfPage.Width, pdfPage.Height), XStringFormats.TopLeft)

graph.DrawString(bezorg_Adres2, font, XBrushes.Black, _
New XRect(350, 175 + (2 * regel_afstand), pdfPage.Width, pdfPage.Height), XStringFormats.TopLeft)

graph.DrawString(bezorg_Postcode_Plaats, font, XBrushes.Black, _
New XRect(350, 175 + (3 * regel_afstand), pdfPage.Width, pdfPage.Height), XStringFormats.TopLeft)

graph.DrawString(bezorg_Land, font, XBrushes.Black, _
New XRect(350, 175 + (4 * regel_afstand), pdfPage.Width, pdfPage.Height), XStringFormats.TopLeft)
End If

graph.DrawString("klant no " & Klanten_nummer, font, XBrushes.Black, _
New XRect(50, 175 + (1 * regel_afstand), pdfPage.Width, pdfPage.Height), XStringFormats.TopLeft)

graph.DrawString("pakbon no " & pakbonnummer, font, XBrushes.Black, _
New XRect(50, 175 + (2 * regel_afstand), pdfPage.Width, pdfPage.Height), XStringFormats.TopLeft)

graph.DrawString("pagina " & pagina_teller, font, XBrushes.Black, _
New XRect(50, 175 + (4 * regel_afstand), pdfPage.Width, pdfPage.Height), XStringFormats.TopLeft)



font = New XFont("courier new", 10, XFontStyle.Underline)
graph.DrawString(" _", font, XBrushes.Black, _
New XRect(10, 238, pdfPage.Width, pdfPage.Height), XStringFormats.TopLeft)

graph.DrawString(" Aantal Code Omschrijving prijs best. bac. _ ", font, XBrushes.Black, _
New XRect(10, 250, pdfPage.Width, pdfPage.Height), XStringFormats.TopLeft)
nieuwe_pagina = False
Else

''################################### artikelen printen ##############################


font = New XFont("courier new", 11, XFontStyle.Regular)

graph.DrawString(RSet(myData("geleverd"), 5), font, XBrushes.Black, _
New XRect(0, 265 + (regel_teller * regel_afstand), pdfPage.Width, pdfPage.Height), XStringFormats.TopLeft)

graph.DrawString(RSet(myData("artikelnummer"), 7), font, XBrushes.Black, _
New XRect(40, 265 + (regel_teller * regel_afstand), pdfPage.Width, pdfPage.Height), XStringFormats.TopLeft)

graph.DrawString(LSet(myData("naam"), 50), font, XBrushes.Black, _
New XRect(95, 265 + (regel_teller * regel_afstand), pdfPage.Width, pdfPage.Height), XStringFormats.TopLeft)

graph.DrawString(RSet(myData("prijs"), 8), font, XBrushes.Black, _
New XRect(430, 265 + (regel_teller * regel_afstand), pdfPage.Width, pdfPage.Height), XStringFormats.TopLeft)

graph.DrawString(RSet(myData("besteld"), 5), font, XBrushes.Black, _
New XRect(490, 265 + (regel_teller * regel_afstand), pdfPage.Width, pdfPage.Height), XStringFormats.TopLeft)

graph.DrawString(RSet(myData("Bacorder"), 5), font, XBrushes.Black, _
New XRect(530, 265 + (regel_teller * regel_afstand), pdfPage.Width, pdfPage.Height), XStringFormats.TopLeft)

regel_teller += 1
End If
If regel_teller = aantal_regels Then
graph.DrawString("Zie volg pagina " & pagina_teller, font, XBrushes.Black, _
New XRect(30, 875 + (regel_teller * regel_afstand), pdfPage.Width, pdfPage.Height), XStringFormats.TopLeft)

regel_teller = 0
pagina_teller += 1
nieuwe_pagina = True

pdfPage = pdf.AddPage
graph = XGraphics.FromPdfPage(pdfPage)


''################### pagina einde ############################
End If

Loop
''End While

Dim pdfFilename As String = "C:\####.pdf"
pdf.Save(pdfFilename)
pdf.Close()
Process.Start(pdfFilename)
End Sub
 
Niemand hier gaat die code doorworstelen als je hem niet eerst tussen CODE tags zet.
 
Sorry maar kunt u mij ook uit leggen hoe ik deze tussen CODE tags zet.
misschien een domme vraag maar zou het niet weten
 
Je zet vóór je code de tag [ CODE ] (zonder de spaties) en áchter de code dit: [ /CODE ]. Ook weer zonder spaties. Je hebt er ook een knop voor: de knop #.
 
Status
Niet open voor verdere reacties.
Terug
Bovenaan Onderaan