Torna al Thread

Try Dim connetionString As String Dim connection As MySqlConnection Dim command As MySqlCommand Dim adapter As New MySqlDataAdapter Dim ds As New DataSet Dim i As Integer Dim sql As String Dim yPoint As Integer Dim pubname As String Dim city As String Dim state As String connetionString = "host=localhost;username=root;password=miapsw;database=miodatabase;port=3306" sql = "select CodiceFiscale,Tipologia,Importo from fattura_dettaglio" connection = New MySqlConnection(connetionString) connection.Open() command = New MySqlCommand(sql, connection) adapter.SelectCommand = command adapter.Fill(ds) connection.Close() Dim pdf As PdfDocument = New PdfDocument pdf.Info.Title = "Database to PDF" Dim pdfPage As PdfPage = pdf.AddPage Dim graph As XGraphics = XGraphics.FromPdfPage(pdfPage) Dim font As XFont = New XFont("Verdana", 10, XFontStyle.Regular) yPoint = yPoint + 100 For i = 0 To ds.Tables(0).Rows.Count - 1 pubname = ds.Tables(0).Rows(i).Item(0) city = ds.Tables(0).Rows(i).Item(1) state = ds.Tables(0).Rows(i).Item(2) graph.DrawString(pubname, font, XBrushes.Black, _ New XRect(40, yPoint, pdfPage.Width.Point, pdfPage.Height.Point), XStringFormats.TopLeft) graph.DrawString(city, font, XBrushes.Black, _ New XRect(200, yPoint, pdfPage.Width.Point, pdfPage.Height.Point), XStringFormats.TopLeft) graph.DrawString(state, font, XBrushes.Black, _ New XRect(420, yPoint, pdfPage.Width.Point, pdfPage.Height.Point), XStringFormats.TopLeft) yPoint = yPoint + 40 Next Dim pdfFilename As String = "dbtopdf.pdf" pdf.Save(pdfFilename) Process.Start(pdfFilename) Catch ex As Exception MsgBox(ex.ToString) End Try
Copyright © 2002-2017
Running on Windows Server 2008 R2 Standard, SQL Server 2012 & ASP.NET 3.5