How to Connect to SQL Server from Visual C++

In this article, we are going to see, step by step, how we can connect to SQL Server from a Visual C++ program using an ODBC connection. Prior to start reading, if you are really interested in learning Programming, then you should definitely check my 6-hour online course, “Introduction to Computer Programming for Beginners“. My … Read more…

There is no argument given that corresponds to the required formal parameter

When working with Inheritance in C#, under certain circumstances, you might get an error message similar to this: There is no argument given that corresponds to the required formal parameter. Don’t worry, the above error can be easily resolved. Let’s see a full example, by first reproducing the error.   Reproducing the Error Message Consider … Read more…

How to Write to a Text File from a C++ Program

Writing to a text file from a C++ Program is very easy. In this example, which is part of my online course on Udemy titled “The Philosophy and Fundamentals of Computer Programming“, I will show you step by step, how to write to a text file from a sample C++ program that generates an array … Read more…

Using the C# SqlParameter Object for Writing More Secure Code

C# SqlParameter is a handy feature allows you to safely pass a parameter to a SqlCommand object in .NET. A security best practice when writing .NET data access code, is to always use parameters in SqlCommand objects (whenever parameters are required of course). The reason for this, is that parameters help prevent SQL injection attacks. … Read more…

How to Establish a Simple Connection from a C# Program to SQL Server

This article, provides a basic example, on how to establish a connection to SQL Server from a C# program with the use of the “using” statement in C# which help you better managing your database connections.   Using the System.Data.SqlClient Use the System.Data.SqlClient namespace in the top section of your code as below: using System.Data.SqlClient;   … Read more…

Cannot implicitly convert type ‘string’ to ‘System.Windows.Forms.DataGridViewTextBoxColumn

When developing a .NET application (i.e. in C#), under certain circumstances, you might get the error message: Cannot implicitly convert type ‘string’ to ‘System.Windows.Forms.DataGridViewTextBoxColumn   Why you got the implicit conversion error If you get the above error, then you have most probably set as a column name for one of your datagridview column the reserved … Read more…

The timeout period elapsed prior to obtaining a connection from the pool

If you are working with .NET applications, at some time you might get the below (or similar) error message: Timeout expired.  The timeout period elapsed prior to obtaining a connection from the pool.  This may have occurred because all pooled connections were in use and max pool size was reached.   Why you get the connection … Read more…

Changing the startup form in a C# project

Open the C# project properties. In the “Application” tab set the Startup object to “WindowsFormsApplication1.Program”. The “WindowsFormsApplication1” reflects the name of your current C# project so it could be different than the project name presented here. Then in the solution explorer, under the project tree, open the “Program.cs” file. The code should be similar as … Read more…