none
creating/printing small receipt with vb.net 2015 and crystal reporst using stored procedure connection to mysql RRS feed

  • Question

  • hi i need creating a for to print recepts, is is possible to use my existing stored procedure of my connection on crystal reports.

    cant use the mysql connector since i'm on windows 10, and would like to use the stored procedure since it is on external file and the connection string will be updated later on.

    and since i cant get crystal reports to work witout the database coneection i'm stuck on creating the receipt, please help!

    will be using an epson TM T20II.

    in advance thanks for the help.

    Wednesday, March 1, 2017 2:33 AM

All replies

  • Hi Oxelotl,

    Here is a sample about Printing under .NET. Take a look here and on msdn. This is a C# version. I think you can covert it to VB language.

    public static void PrintReceiptForTransaction()
        {
    
            PrintDocument recordDoc = new PrintDocument();
    
            recordDoc.DocumentName = "Customer Receipt";
            recordDoc.PrintPage += new PrintPageEventHandler(ReceiptPrinter.PrintReceiptPage); // function below
            recordDoc.PrintController = new StandardPrintController(); // hides status dialog popup
            // Comment if debugging 
            PrinterSettings ps = new PrinterSettings();
            ps.PrinterName = "EPSON TM-T20II Receipt";
            recordDoc.PrinterSettings = ps;
            recordDoc.Print();
            // --------------------------------------
    
            // Uncomment if debugging - shows dialog instead
            //PrintPreviewDialog printPrvDlg = new PrintPreviewDialog();
            //printPrvDlg.Document = recordDoc;
            //printPrvDlg.Width = 1200;
            //printPrvDlg.Height = 800;
            //printPrvDlg.ShowDialog();
            // --------------------------------------
    
            recordDoc.Dispose();
    
        }
    
    
    private static void PrintReceiptPage(object sender, PrintPageEventArgs e)
        {
            float x = 10;
            float y = 5;
            float width = 270.0F; // max width I found through trial and error
            float height = 0F;
    
            Font drawFontArial12Bold = new Font("Arial", 12, FontStyle.Bold);
            Font drawFontArial10Regular = new Font("Arial", 10, FontStyle.Regular);
            SolidBrush drawBrush = new SolidBrush(Color.Black);
    
            // Set format of string.
            StringFormat drawFormatCenter = new StringFormat();
            drawFormatCenter.Alignment = StringAlignment.Center;
            StringFormat drawFormatLeft = new StringFormat();
            drawFormatLeft.Alignment = StringAlignment.Near;
            StringFormat drawFormatRight = new StringFormat();
            drawFormatRight.Alignment = StringAlignment.Far;
    
            // Draw string to screen.
            string text = "Company Name";
            e.Graphics.DrawString(text, drawFontArial12Bold, drawBrush, new RectangleF(x, y, width, height), drawFormatCenter);
            y += e.Graphics.MeasureString(text, drawFontArial12Bold).Height;
    
            text = "Address";
            e.Graphics.DrawString(text, drawFontArial10Regular, drawBrush, new RectangleF(x, y, width, height), drawFormatCenter);
            y += e.Graphics.MeasureString(text, drawFontArial10Regular).Height;
    
            // ... and so on
    
     }

    >>cant use the mysql connector since i'm on windows 10, and would like to use the stored procedure since it is on external file and the connection string will be updated later on.

    I am afraid since MySQL is third-party product here. It is out of topic here. Please ask in MySQL official forum for better support.

    Best regards,

    Kristin


    MSDN Community Support
    Please remember to click "Mark as Answer" the responses that resolved your issue, and to click "Unmark as Answer" if not. This can be beneficial to other community members reading this thread. If you have any compliments or complaints to MSDN Support, feel free to contact MSDNFSF@microsoft.com.

    • Proposed as answer by Kristin Xie Friday, March 3, 2017 1:24 AM
    Thursday, March 2, 2017 1:55 AM
  • Thanks so much, this was is really helpfull
    Thursday, March 2, 2017 7:05 AM