Insert Update Delete example in C# and VB.NET Using ExecuteNonQuery method

ExecuteNonQuery is a method from the SQlCommand Class in the System.Data.SqlClient namespace. It executes a T-SQL query and returns the number of rows affected. Below are examples of how to run an Insert, Delete, and Update statements using the ExecuteNonQuery method in both C# and VB.NET. Required namespaces C# using System.Data; using System.Data.SqlClient; VB.NET Imports... » read more

Bind chart control using C# and Linq

Charts are popular and can help to visualize the data in a WinForm application. This tutorial will focus on how to create and bind charts using C# and Linq. To better understand this tutorial, you should know the following C# programming area: C# ‘for’ Loop Here are the steps to proceed with the tutorial: 1- Create... » read more

Populate DataTable using DataReader in C#

Below is an example of how to populate a DataTable using a DataReader in C#. First, let’s create the database table as showing below: Design View SQL CREATE TABLE [dbo].[ProgrammingLanguage] ( [ID] INT NOT NULL, [LanguageName] NVARCHAR (50) NULL, PRIMARY KEY CLUSTERED ([ID] ASC) ); Then add a few records to that table: Now create... » read more

Send SMTP email in ASP.NET

Here is an example of sending an email in ASP.NET using the SMTP server. First, add the namespace. using System.Web.Mail; And the function. C# private bool SendMail(String SendTo, String sendToCC, string SendFrom, string Subject, string msg) { bool bSuccess; try { MailMessage mail = new MailMessage(); mail.To = SendTo; mail.Cc = sendToCC; // to send... » read more

RowDataBound Event in GridView in ASP.NET

GridView.RowDataBound is an event in GridView controls in ASP.NET. It occurs when a data row is bound to data in the GridView. Below are examples of how to use this even when binding data to the GridView using C# and VB.NET. First, let’s create a Visual Studio ASP.NET Application C#. Note: We will show the code... » read more

Bind an ADO.NET DataTable to a ListBox using C#

This tutorial will teach you how to bind a ListBox in C#. First, open Visual Studio, create a C# windows application project and then add a ListBox to the main form of that application. Create the table in Microsoft SQL Server as shown below. SQL Code USE [TutorialsPanel] GO SET ANSI_NULLS ON GO SET QUOTED_IDENTIFIER... » read more

Get local IP address list using C#

Use the Static method Dns.GetHostAddresses to get a list of computer IP Addresses. First, you need to to get the Computer name. Then pass it as a parameter to the Dns.GetHostAddresses method. Required Namespace: System.Net C# String ComputerName= Dns.GetHostName(); IPAddresses[] localIPs = Dns.GetHostAddresses(ComputerName);

Get words count in a string using VB.NET

Below is a simple function that takes one string argument and returns the word count in that string. In this function, we will use the following VB.NET built-in function: UBound: a function that returns the highest subscript for the indicated dimension of an array. Split: a function that splits strings. It extracts the substrings from... » read more

Create an Auto-complete ComboBox using VB.NET

This tutorial will teach you how to create an auto-complete ComboBox in a WinForm application. Auto-complete ComboBox is very useful when there are too many items in it. Auto-complete ComboBox using VB.NET First, we need to create a SQL Server database: Design View Data View Related Auto-Complete ComboBox Using C# Now open visual studio and... » read more