The COBOL compiler for Windows

This blog article shows you how to compile COBOL program in Windows. It is pretty hard to find COBOL compiler. Those compiler links in the Internet are either broken or extreme commence such as Visual COBOL. Till now I only found a free COBOL compiler GnuCOBOL that is quite good to run the legacy code. You can either download it from SourceForge, https://gnucobMinGW ol.sourceforge.io/, you need to compile using MinGW or you can download the one already built here.

Copy the build version into C:\gnucobol or other directory that you prefer. Add C:\gnucobol\bin to Path environment variable.


The best COBOL book for learn I found is https://www.bookdepository.com/Sams-Teach-Yourself-COBOL-21-Days-Second-Edition-Mo-Budlong/9780672311376/?WT.mc_id=DP-MVP-36769. Although it is from 1997. The code you can paste to GnuCOBOL and compile with the lesser issue than other COBOL books.

To test the compiler, you can copy and paste the code from the book as template like below.

000100 IDENTIFICATION DIVISION.

000200 PROGRAM-ID. HELLO.

000300 ENVIRONMENT DIVISION.

000400 DATA DIVISION.

000500 PROCEDURE DIVISION.

000700 PROGRAM-BEGIN.

000800 DISPLAY “I said, Hello world”.

001000 PROGRAM-DONE.

001100 STOP RUN.

Save as hello.cob. Start a command prompt and type cobol -t- hello.cob.


Then you will get the exe. Run the exe. You will see the result below.


References: https://bigdanzblog.wordpress.com/2020/05/05/installing-gnucobol-on-windows/?WT.mc_id=DP-MVP-36769

Posted in Community, Computers and Internet, Data Platform, management | Tagged | Leave a comment

SQL Server Encrypt the data transfer using TDS Protocol C#

This blog article shows how to encrypt the data from TDS protocol when using ADO.NET. This article expects you to have minimum networking, C# and SQL Server knowledge. At first, I setup the Client / Server environment. The server equipped with MS SQL Server with northwind database and WireShark to capture the TDS traffic. The client will run the C# code.

When run the following code.

public static void TestTDS()

{

    string connectionString = “Server=172.29.99.222;Database=northwind;UserID=sa;Password=password;MultipleActiveResultSets=True;”;

    string strSql = “SELECT TOP 10 * FROM Products”;

    SqlConnection conn = new SqlConnection(connectionString);

    conn.Open();

    SqlCommand cmd = new SqlCommand(strSql, conn);

    SqlDataReader rd = cmd.ExecuteReader();

}

You can capture and find the SELECT statement issue to the SQL Server via WireShark.


You can also see what data is returning to the client using WireShark.


To avoid this from happening add Encrypt=Yes;TrustServerCertificate=Yes to the connection string.

string connectionString = “Server=172.29.99.222;Database=northwind;User ID=sa;Password=password;MultipleActiveResultSets=True;Encrypt=Yes;TrustServerCertificate=Yes”;

When you run the program again, the data will no longer be captured by WireShark of other network analyzers.


Source code download: https://github.com/chanmmn/database/tree/main/ConAppEncrypt/?WT.mc_id=DP-MVP-36769

Reference:

What is TDS protocol https://docs.microsoft.com/en-us/openspecs/windows_protocols/ms-tds/b46a581a-39de-4745-b076-ec4dbb7d13ec/?WT.mc_id=DP-MVP-36769

Using Encrypt=yes in a Sql Server connection string -> “provider: SSL Provider, error: 0 – The certificate’s CN name does not match the passed value.” https://stackoverflow.com/questions/3674160/using-encrypt-yes-in-a-sql-server-connection-string-provider-ssl-provider/?WT.mc_id=DP-MVP-36769

Posted in .Net, Cloud, Community, Computers and Internet, Data Platform | Tagged | Leave a comment

Applied Queue and Delegate in C#

This blog article illustrates one of the possible ways to apply Queue in C#. Many web links just tell you Queue is First-in first-out (FIFO) but when can you apply it to your application. One of the thoughts is that, you can use it together with Delegate to insert a record into a database. The below program conceptually insert the record to the database and dequeue if it is insert successfully.

namespace Queue_Delegates

{

    public class RecordStorage

    {

        public delegate int InsertTable();

        string value = “”;

        public void ReportResult(InsertTable InsertDelegate)

        {

            //Successfully insert then dequeue

            if (InsertDelegate() == 0)

            {

                Console.WriteLine(“Insert successfully.”);

                value = QueueData.recordqueue.Dequeue();

                Console.WriteLine(“Dequque {0}”, value);

            }

            else

            {

                Console.WriteLine(“Insert not play successfully.”);

            }

        }

    }

    public static class QueueData

    {

        public static Queue<string> recordqueue = new Queue<string>();

    }

    public class AccountTable

    {

        private int InsertStatus;

        string value = “”;

        public int InsetData()

        {

            Console.WriteLine(“Simulating Insert Record.”);

            value = QueueData.recordqueue.Peek();

            Console.WriteLine(“Insert {0}”, value);

            InsertStatus = 0;

            return InsertStatus;

        }

    }

    public class Tester

    {

        public void Run()

        {

            RecordStorage myRecordStorage = new RecordStorage();

            // instantiate the Account Table

            AccountTable accountTable = new AccountTable();

            // instantiate the delegates

            RecordStorage.InsertTable InsertDelegate = new

                 RecordStorage.InsertTable(accountTable.InsetData);

            // call the delegates

            while(QueueData.recordqueue.Count > 0)

            {

                myRecordStorage.ReportResult(InsertDelegate);

            }

        }

    }

    class Program

    {

        static void Main(string[] args)

        {

            QueueData.recordqueue.Enqueue(“Record1”);

            QueueData.recordqueue.Enqueue(“Record2”);

            QueueData.recordqueue.Enqueue(“Record3”);

            QueueData.recordqueue.Enqueue(“Record4”);

            QueueData.recordqueue.Enqueue(“Record5”);

            Tester t = new Tester();

            t.Run();

        }

    }

}

You will see the below output when you are running the program.


The thing that is not handle in this program is how many retry is needed if the insert fails.

Source code download: https://github.com/chanmmn/general/tree/master/ConsAppQueue/?WT.mc_id=DP-MVP-36769

Resources: https://docs.microsoft.com/en-us/dotnet/api/system.collections.generic.queue-1?view=net-6.0/?WT.mc_id=DP-MVP-36769

https://docs.microsoft.com/en-us/previous-versions/visualstudio/visual-studio-2008/ff652490(v=orm.10)/?WT.mc_id=DP-MVP-36769

Posted in .Net, Cloud, Community, Computers and Internet, Data Platform | Tagged , , | Leave a comment

Great Expectations: Making Hybrid Work Work

From when to go to the office to why work in the first place, employees have a new ‘worth it’ equation. And there’s no going back. Microsoft’s second annual Work Trend Index highlights the data behind how work has changed over the last two years. With more than 31,000 people surveyed in 31 countries, Great Expectations, Making Hybrid Work Work gives business leaders the insights they need about what’s in store for the future of labour trends and how to protect their bottom line.

In this exclusive study, you’ll learn about:

  • How leaders need to make the office worth the commute
  • Rebuilding social capital in a hybrid world
  • Bridging gaps between employee expectations and leadership priorities for long-term business success

(Read it now, I am not sure how long Microsoft will leave the link alive).

Read the report: https://bit.ly/3FfNZzK

Posted in .Net, Cloud, Community, Computers and Internet, CTO, Data Platform | Tagged | Leave a comment

SSIS Text File Destination – Rows not breaking at end of line

This blog article shows you how to export SQL Server records to Flat File with {CR}{LR} after every record. This is one of the famous topics in Google search. This article expects you have certain knowledge on SSIS. I have created a Data Flow to export the data from Northwind Product table to a Flat File.

I have configured the Format as Fixed width.

When I executed the package, the result as following. You will realize that there is no line break {CR}{LF} after each record.

When I opened the Advanced option and checked on the last column ProductName, the ColumnDelimiter is greyed out.

What I have done to get the line break is that I changed the Format to Ragged right.

When I executed the package, I have gotten the following output.

When I opened the Advanced option and checked on the last column ProductName, the ColumnDelimiter with the value {CR}{LF}..


References: https://www.sqlservercentral.com/forums/topic/ssis-text-file-destination-rows-not-breaking-at-end-of-line/?WT.mc_id=DP-MVP-36769

https://docs.microsoft.com/en-us/sql/integration-services/data-flow/flat-file-destination?view=sql-server-ver15/?WT.mc_id=DP-MVP-36769

Posted in .Net, Cloud, Community, Computers and Internet, Data Platform | Tagged , | Leave a comment

COBOL Pad space to column 8 using C#

This blog article shares a program that can pad the necessary space for COBOL compiler to compile the source code. COBOL compiler needs the source code to start with column 8. If you download a document from IBM. You copy the source code below.


When you paste it to it to a text editor you will get everything starts in column 1.


I have written a simple program to pad the source code to start on column 8.

public static void ReadWriteString(string strInFile, string strOutFile)

{

    String strLine;

    List<string> strList = new List<string>();

    StreamReader streamReader = new StreamReader(strInFile);

    StreamWriter sw = new StreamWriter(strOutFile);

    while (!streamReader.EndOfStream)

    {

        //Read line

        strLine = streamReader.ReadLine();

        //Add 7 spaces

        strLine = ”     “ + strLine;

        //Write a line of text

        sw.WriteLine(strLine);

    }

    streamReader.Close();

    sw.Close();

}

You can download the utility using the link below.

Source code download: https://github.com/chanmmn/general/tree/master/ConeAppPad7/?WT.mc_id=DP-MVP-36769

https://docs.microsoft.com/en-us/dotnet/api/system.io.streamwriter?view=net-6.0/?WT.mc_id=DP-MVP-36769

Posted in .Net, Cloud, Community, Computers and Internet, Data Platform | Tagged | Leave a comment

Upgrade from Windows Server 2016 Standard to Windows Server 2019 Standard

The blog article shows you one of the ways to upgrade Windows Server 2016 to Windows Server 2019. The reason for me to upgrade is Windows Server 2016 always Stuck on Getting Windows Ready during shutdown.

To upgrade from Windows Server 2016 to Windows Server 2019. Get the Windows Server 2019 iso file. Run the Setup.exe. The installation will ask whether you want to check for update. Select Yes and click Next.

Select Windows Server 2019 Standard (Desktop Experience) else you will not have GUI for your Windows Server.

You can upgrade to an empty OS with the option Nothing. For me I Keep personal files and apps. So that, all the Windows Account and Application that I installed such as Visual Studio will be still there after upgrading to Windows Server 2019.

The update download will begin.

Click Install to proceed with the Operating System update.

Installation in progress.

Finalizing the installation of Windows Server 2019.

Done, for me. The upgrade is pretty seamless.

Reference: https://docs.microsoft.com/en-us/answers/questions/405924/suck-on-getting-windows-ready.html/?WT.mc_id=DP-MVP-36769

https://docs.microsoft.com/en-us/windows-server/upgrade/upgrade-2016-to-2019/?WT.mc_id=DP-MVP-36769

Posted in .Net, Cloud, Community, Computers and Internet, Operating System | Tagged | Leave a comment

Discover five ways to accelerate digital transformation in manufacturing

Drive innovation and empower your workforce with five key digital transformation strategies. In this eBook, A Five-Part Guide to Digital Transformation: Learn How Manufacturers Can Build a More Resilient and Sustainable Future, explore how to:


  • Engage customers in new ways.
  • Transform your workforce.
  • Build more agile factories.
  • Create more resilient supply chains.
  • Unlock innovation and deliver new services.

Plus, learn strategies to build a more resilient and sustainable future with Microsoft Cloud for Manufacturing.

(Read it now, I am not sure how long Microsoft will leave the link alive).

eBook download: https://bit.ly/3w79wqn

Posted in .Net, Cloud, Community, Computers and Internet, CTO, Data Platform | Tagged | Leave a comment

Educational Azure Data Factory Resource

This blog article provides the collective Azure Data Factory learning resources to get you started with Azure Data Factory. You can find tutorials, Quickstarts, and other educational resources below.

Introduction to Azure Data Factory

https://docs.microsoft.com/en-us/learn/modules/intro-to-azure-data-factory/?WT.mc_id=DP-MVP-36769

Create production workloads on Azure Databricks with Azure Data Factory

https://docs.microsoft.com/en-us/learn/modules/create-production-workloadazure-databricks-azure-data-factory/?WT.mc_id=DP-MVP-36769

Send and receive data using Azure Data Share and transform data using Azure Data Factory

https://docs.microsoft.com/en-us/learn/modules/receive-data-with-azure-data-share-transforming-with-azure-data-factory/?WT.mc_id=DP-MVP-36769

Integrate data with Azure Data Factory or Azure Synapse Pipeline

https://docs.microsoft.com/en-us/learn/modules/data-integration-azure-data-factory/?WT.mc_id=DP-MVP-36769

Azure Data Factory documentation

https://docs.microsoft.com/en-us/azure/data-factory/?WT.mc_id=DP-MVP-36769

Azure Data Factory tutorials

https://docs.microsoft.com/en-us/azure/data-factory/data-factory-tutorials/?WT.mc_id=DP-MVP-36769

Posted in .Net, Cloud, Community, Computers and Internet, Data Platform | Tagged | Leave a comment

CS1935 Could not find an implementation of the query pattern for source type. ‘Select’ not found. Are you missing required assembly references or a using directive for ‘System.Linq’

This blog article shows you one of the possible ways to resolve the error below. I have declared an Array of Object as follow:

MasterCustomerDaily[] customer = new MasterCustomerDaily[5];

So, I should be eligible to use the following LINQ statement.

var cus = from res in customer select res;

Somehow, I hit an error like the one below.


CS1935    Could not find an implementation of the query pattern for source type ‘MasterCustomerDaily[]’. ‘Select’ not found. Are you missing required assembly references or a using directive for ‘System.Linq’

For the expert C# developer, the error seems straightforward but for the beginner it might take awhile to figure out.

To resolve this error, you just need to include this directive on top of your code.

using System.Linq;

References: https://docs.microsoft.com/en-us/dotnet/csharp/programming-guide/concepts/linq/?WT.mc_id=DP-MVP-36769

https://docs.microsoft.com/en-us/dotnet/standard/linq/?WT.mc_id=DP-MVP-36769

Posted in .Net, Cloud, Community, Computers and Internet, Data Platform | Leave a comment