Category - C#.Net
4 Comments   94738 Views
Here Mudassar Ahmed Khan has explained how to use parameterized queries to query SQL Server database in order to avoid SQL Injection attacks
1 Comments   64944 Views
Here Mudassar Ahmed Khan has explained how to export data to Microsoft Excel workbook using ADO.Net and C#
1 Comments   34937 Views
Here Mudassar Ahmed Khan has explained how to make AJAX Calls using JavaScript and XMLHttp to fetch data from server in ASP.Net
1 Comments   38882 Views
Here Mudassar Ahmed Khan has explained how to use AJAX JavaScript and XMLHttp to query the server and find out whether user name already exists in the database using C and Vb.Net
11 Comments   106612 Views
Here Mudassar Ahmed Khan has explained how to read and import data to Microsoft Excel workbook using ADO.Net and C#
12 Comments   58107 Views
Here Mudassar Ahmed Khan has explained how to send emails using C# and asp.net. He has also explained how to send emails on a new thread to improve performance.
9 Comments   43232 Views
Here Mudassar Ahmed Khan has explained how to attach files to email without saving them onto the disk directly from the FileUpload stream
79 Comments   231642 Views
Here Mudassar Ahmed Khan has explained how to save file as binary data inside SQL Server database and also how to retreive them and reconvert to their respective formats using VB.net amd C#.
49 Comments   325703 Views
Here Mudassar Ahmed Khan has explained how to retrieve and display images that are stored in SQL Server Database in ASP.Net Web application
9 Comments   67693 Views
Here Mudassar Khan has explained How to display images that are stored outside the Website Root Folder
18 Comments   65217 Views
Here Mudassar Ahmed Khan has explained how to pull RSS from a website and display the same on the web page using ASP.Net
10 Comments   118338 Views
Here Mudassar Ahmed Khan has explained how to find the control that caused the postback in ASP.Net
21 Comments   54941 Views
Here Mudassar Ahmed Khan has explained how to call parent page method from child user control placed on the same page whose function or method we want to call.
2 Comments   19899 Views
Here Mudassar Ahmed Khan has explained how to Populate and Bind Custom Business Objects or properties collection to databound controls like ASP.Net GridView Control
5 Comments   21155 Views
Here Mudassar Ahmed Khan has explained how to bind an XML or XML File to ASP.Net DropDownList Control using DataSet in C# and VB.Net
0 Comments   43804 Views
Here Mudassar Ahmed Khan has explained how to preserve values or states of custom properties across postbacks in ASP.Net
3 Comments   27846 Views
Here Mudassar Ahmed Khan has explained how to make use of the new feature Parallelism in .Net 4.0 making use of the new classes Parallel and PLINQ (Parallel LINQ)
4 Comments   181616 Views
Here Mudassar Ahmed Khan has explained how to list the installed instances of SQL Server on machine and LAN Network using C# and VB.Net
18 Comments   77221 Views
In this article Mudassar Ahmed Khan has explained how to read emails from POP3 server using OpenPop.Net Library using C# and VB.Net
10 Comments   45693 Views
In this article Mudassar Ahmed Khan has explained how to read emails from POP3 server using OpenPop.Net Library using C# and VB.Net
1 Comments   10582 Views
Here Mudassar Ahmed Khan has explained the difference between string and String keywords in C# and also the difference between bool and Boolean class.
18 Comments   108838 Views
Here Mudassar Ahmed Khan has explained how to create and send HTML Formatted Emails in ASP.Net using C# and VB.Net
Here Mudassar Ahmed Khan has explained how to implement the free ASP.Net Mathematical Captcha Control in C# and VB.Net
Here Mudassar Ahmed Khan has explained the exception DataBinding: 'System.Data.DataRowView' does not contain a property with the name 'ID' in ASP.Net
10 Comments   62595 Views
Here Mudassar Ahmed Khan has explained how to modify the ASP.Net WCF (Windows Communication Foundation) service to make it accept AJAX JSON calls and to make AJAX JSON calls to ASP.Net WCF Service using JavaScript and jQuery
0 Comments   23911 Views
Here Mudassar Ahmed Khan has explained how to get distinct list of custom business class objects using LINQ Query in .Net
5 Comments   48963 Views
Here Mudassar Ahmed Khan has explained how to convert Text string to Image using C# and VB.Net in ASP.Net Web application and display the converted image in Image Control
3 Comments   36599 Views
Here Mudassar Ahmed Khan has explained how to programmatically add and update SQL connection strings in ASP.Net Web.Config file using C# and VB.Net.
He has explained how we can access and update the different attributes of a connection string like DataSource, IntitialCatalog, UserId, Password and IntegratedSecurity.
8 Comments   66475 Views
Here Mudassar Ahmed Khan has explained how to fetch and read email messages with attachments from GMAIL POP3 mail server inbox in ASP.Net. The fetched emails are bound to ASP.Net GridView and users are able to download the attachments.
6 Comments   54892 Views
Here Mudassar Ahmed Khan has explained how to send Rich Text HTML Emails with embedded images and pictures using VB.Net and C# in ASP.Net
Here Mudassar Ahmed Khan has explained how to create dynamic button controls at runtime and also attach OnClick event handlers to the dynamically generated buttons in Windows Forms (WinForms) Application using VB.Net and C#.
2 Comments   56058 Views
Here Mudassar Ahmed Khan has explained with an example and attached sample code how to minimize Windows Application to System Tray using VB.Net and C#.
0 Comments   47286 Views
Here Mudassar Ahmed Khan has explained with an example and attached sample code, how to Populate bind GridView with Generic List in ASP.Net using C# and VB.Net.
Generic Lists are created from Custom Business Objects also known as Property Class
0 Comments   24191 Views
Here Mudassar Ahmed Khan has explained with an example and attached sample code, how to bind Generic List to GridView in ASP.Net using C# and VB.Net.
Generic Lists are created from Custom Business Objects also known as Property Class
0 Comments   14041 Views
Here Mudassar Ahmed Khan has explained with an example, how to delete folder or directory using C# and VB.Net
A Directory that contains files or folders cannot be deleted hence this code first deletes all the Child Directories and also all the files in the Directory as well the Child Directories.
0 Comments   21684 Views
Here Mudassar Ahmed Khan has explained with an example, how to recursively all delete all directories (sub directories or folders or sub folders) in C# an VB.Net
0 Comments   8887 Views
Here Mudassar Ahmed Khan has explained with an example and attached sample code,
how to send emails using GMAIL Account Credentials in ASP.Net using C#.
0 Comments   45231 Views
Here Mudassar Ahmed Khan has explained, how to populate DropDownList from XML file in ASP.Net
6 Comments   47617 Views
Here Mudassar Ahmed Khan has explained, how to send email with attachment in ASP.Net.

The file to be send as attachment along with mail will be uploaded using FileUpload control and will be dynamically added as attachment in the MailMessage class object without saving in any folder on disk.

For this example, for sending emails Gmail SMTP Mail Server will be used. To send email with Gmail SMTP Server, you will need to use an email address and password of a valid Gmail account and along with that you will need the Gmail SMTP Mail Server settings.
1 Comments   37264 Views
Here Mudassar Ahmed Khan has explained, how to remove (delete) duplicate rows (records) from DataTable using DataView in C# and VB.Net.

The idea is to convert the DataTable to DataView and then from DataView back to DataTable using the DataView ToTable method which has option to return distinct (unique) rows (records) of DataTable, thus ultimately it removes (deletes) duplicate rows (records).
4 Comments   50428 Views
Here Mudassar Ahmed Khan has explained, how to add dynamic controls like Label, TextBox, Button, etc. to Windows Forms ( WinForms ) Application on click of a Button.

He has also explain how we can attach event handler to various dynamically added controls like TextBox, Button, etc.
0 Comments   9256 Views
Here Mudassar Ahmed Khan has explained with an example, how to recursively all delete files in all directories (sub directories or folders or sub folders) in C# and VB.Net
2 Comments   96716 Views
Here Mudassar Ahmed Khan has explained, how to dynamically (programmatically) at runtime create a DataTable using C# or VB.Net and then bind it to GridView in ASP.Net.

First a dynamic DataTable object is created and its schema (Table structure and Columns) is defined programmatically. Once the columns are defined, then rows (records) are added to the dynamically generated DataTable.

Once the dynamic DataTable is populated with records, it is bound to an ASP.Net GridView control.
1 Comments   35531 Views
Here Mudassar Ahmed Khan has explained, how to dynamically create DataTable and bind to GridView in ASP.Net using C# and VB.Net
21 Comments   76869 Views
Here Mudassar Ahmed Khan has explained, the difference between ArrayList and Generic List (List) in C# .Net and VB.Net.
6 Comments   23763 Views
Here Mudassar Ahmed Khan has explained, how to send email with attachment in ASP.Net.

The file to be send as attachment along with mail will be uploaded using FileUpload control and will be dynamically added as attachment in the MailMessage class object without saving in any folder on disk.

For this example, for sending emails Gmail SMTP Mail Server will be used. To send email with Gmail SMTP Server, you will need to use an email address and password of a valid Gmail account and along with that you will need the Gmail SMTP Mail Server settings.
12 Comments   112126 Views
Here Mudassar Ahmed Khan has explained how to use and return value from Stored Procedure using Output Parameter in ASP.Net.

For this article I a Table named Fruits is used which contains FruitId and FruitName columns. The name of the Fruit is fetched using Output Parameter in SQL Server Stored Procedure in ASP.Net
3 Comments   34131 Views
Here Mudassar Ahmed Khan has explained how to programmatically add, modify (change) and update SQL connection strings at runtime in ASP.Net Web.Config file using C# and VB.Net.

He has explained how we can access and update the different attributes of a connection string like DataSource, IntitialCatalog, UserId, Password and IntegratedSecurity.
3 Comments   36910 Views
Here Mudassar Ahmed Khan has explained how to encrypt and decrypt file such as Word (DOC, DOCX), Excel (XLS, XLSX), PDF, Text (TXT) documents or JPG, PNG or GIF Images using C# and VB.Net in ASP.Net website.

The file will be uploaded for Encryption and Decryption of Files. For Encryption and Decryption of files, the AES Symmetric key (Same key) algorithm is used. The encrypted and decrypted files can be saved inside folders on disk or can be downloaded to client user.
0 Comments   37133 Views
Here Mudassar Ahmed Khan has explained how to modify the ASP.Net WCF (Windows Communication Foundation) service to make it accept AJAX JSON calls and to make AJAX JSON calls to ASP.Net WCF Service using JavaScript and jQuery
3 Comments   46441 Views
Here Mudassar Ahmed Khan has explained how to read Excel File using OLEDB Data Provider Connection in C# .Net. Excel Workbook is just like database with sheets corresponding to tables.
This article covers reading of both Excel 2003 as well as OpenXML i.e. Excel 2007, 2010 and 2013 formats.
1 Comments   19201 Views
Here Mudassar Ahmed Khan has explained how to preserve or persists data / class objects / variable values across PostBacks in ASP.Net.

This is done by saving the data / class objects / variable in a ViewState object and then fetching it from it whenever needed.
2 Comments   15923 Views
Here Mudassar Ahmed Khan has explained how to encrypt and decrypt XML File using C# and VB.Net.

The XML file will be uploaded for Encryption and Decryption of Files. For Encryption and Decryption of files, the AES Symmetric key (Same key) algorithm is used. The encrypted and decrypted files can be saved inside folders on disk or can be downloaded to client user.
7 Comments   20504 Views
Here Mudassar Ahmed Khan has explained how to send or pass DataTable as parameter to Stored Procedure in C# and VB.Net using the SQL Server User Defined Table Type.

The User Defined Table Type has to be created in SQL Server and it must have the same schema as that of the DataTable that we need to pass to the Stored Procedure as parameter.
0 Comments   15326 Views
Here Mudassar Ahmed Khan has explained how to display ‘st’, ‘nd’, ‘rd’ and ‘th’ suffix after day numbers in Formatted Date string using C# and VB.Net.

By default .Net does not have any provision to display the display ‘st’, ‘nd’, ‘rd’ and ‘th’ suffix after day numbers in Formatted Date string and hence I have come up with a generic method for accomplishing the task.
2 Comments   16012 Views
Here Mudassar Ahmed Khan has explained how to dynamically generate PDF in Memory from HTML using iTextSharp and send the generated PDF as Email Attachment using C# and VB.Net.

Using iTextSharp Library, the PDF is generated from HTML string in memory by making use of MemoryStream class and then the same is attached to the MailMessage object and send as email attachment.
3 Comments   26733 Views
Here Mudassar Ahmed Khan has explained how to read and write BLOBs (Binary Large Objects) data to SQL Server database using C# and VB.Net.

BLOBs include files such as Images, PDF, Word or Excel Documents, Audio, Video files. Such files are read converted to an array of bytes and inserted into SQL Server VARBINARY or IMAGE fields.
0 Comments   16761 Views
Here Mudassar Ahmed Khan has explained how to dynamically create PDF from HTML string using iTextSharp and send the generated PDF as Email Attachment in ASP.Net using C# and VB.Net.
1 Comments   21089 Views
Here Mudassar Ahmed Khan has explained with a simple example how to use Parallel ForEach Loop in C# and VB.Net using .Net 4.0 and .Net 4.5.

Parallelism can be achieved in two ways
1. Parallel class
2. PLINQ (Parallel LINQ)

Here he has explained how to achieve parallelism using Parallel ForEach Loop.
Here Mudassar Ahmed Khan has explained what is Parallel LINQ (PLINQ) and a simple example how to write a PLINQ Query in C# and VB.Net .Net 4.0 and .Net 4.5.

Parallelism can be achieved in two ways
1. Parallel class
2. PLINQ (Parallel LINQ)

Here he has explained how to achieve parallelism using Parallel LINQ (PLINQ).
1 Comments   8075 Views
Here Mudassar Ahmed Khan has explained with an example, how to pass Table Valued Parameters to SQL Server Stored Procedure from .Net Code Behind using ADO.Net, C# and VB.Net.
1 Comments   14257 Views
Here Mudassar Ahmed Khan has explained how to pass multiple records (rows) to a Stored Procedure in SQL Server using C# and VB.Net.
We can pass a Table containing multiple records (rows) to a Stored Procedure by making use of Table Valued parameters in SQL Server.
0 Comments   6748 Views
Here Mudassar Ahmed Khan has explained how to save file as binary data inside SQL Server database and also how to retrieve them and convert them back to their respective formats using C# and VB.Net.
0 Comments   11752 Views
Here Mudassar Ahmed Khan has explained how to save image as binary data into SQL Server database and also how to retrieve and convert the image back to their respective formats using C# and VB.Net.
1 Comments   7548 Views
Here Mudassar Ahmed Khan has explained how to create text image on the fly with ASP.Net using C# and VB.Net.

The image generation is done dynamically using GDI+ library in ASP.Net.
0 Comments   11517 Views
Here Mudassar Ahmed Khan has explained how to export data (records) from SQL Server Table to Text (Notepad) file in ASP.Net using C# and VB.Net. This article will work for all SQL Server versions i.e. 2005, 2008, 2008R2, 2012, etc.

The data will be first fetched into a DataTable and then the DataTable will be exported to a Text file which can be viewed in Notepad.
Here Mudassar Ahmed Khan has explained how to export DataGridView data to Excel file in Windows Forms (WinForms) Applications using OpenXml and ClosedXml Excel conversion libraries, C# and VB.Net.

DataGridView cannot be exported directly to Excel file and hence need to generate a DataTable and export the DataTable to Excel file.
0 Comments   4462 Views
Here Mudassar Ahmed Khan has explained how to Rotate / Flip / Transpose DataTable - Convert DataTable Columns to Rows and Rows to Columns using C# and VB.Net.
He has also explained how we can get back the original DataTable from the Rotated / Flipped / Transposed DataTable using C# and VB.Net.
3 Comments   7005 Views
Here Mudassar Ahmed Khan has explained how to insert (save) Hindi, Marathi, Gujarati, Urdu, Persian, Arabic, Tamil and Telugu languages Text characters in SQL Server database using ASP.Net, C# and VB.Net.

In SQL Server database we will need to use NVARCHAR data type to store the various languages text characters.
Here Mudassar Ahmed Khan has explained how to dynamically generate and display barcode image in Windows Forms (WinForms) Application using C# and VB.Net.
0 Comments   2185 Views
Here Mudassar Ahmed Khan has explained how to Rotate / Flip / Transpose DataTable - Convert DataTable Columns to Rows and Rows to Columns using C# and VB.Net.
He has also explained how we can get back the original DataTable from the Rotated / Flipped / Transposed DataTable using C# and VB.Net.
0 Comments   3945 Views
Here Mudassar Ahmed Khan has explained how to add page numbers to existing PDF file using iTextSharp in C# and VB.Net.
The pages of the PDF file will be read and then using the PdfStamper class page numbers will be written to each page of the PDF document.
0 Comments   1476 Views
Here Mudassar Ahmed Khan has explained a tutorial with example on how to use the JavaScript XmlHttpRequest to make Asynchronous calls to the server and fetch data.
1 Comments   9564 Views
Here Mudassar Ahmed Khan has explained with examples, how to calculate Sum (Total) of DataTable Columns using C# and VB.Net.

This article explains how to calculate Sum (Total) of DataTable Columns using the following two methods.
1. DataTable Compute function.
2. Using LINQ.
0 Comments   2472 Views
Here Mudassar Ahmed Khan has explained how to create and drop (delete) SQL Server Table programmatically using ADO.Net, C# and VB.Net.

The Create and Drop script will be dynamically generated and the Table will be respectively created or deleted in SQL Server database.
0 Comments   2281 Views
C#.Net   VB.Net   XML
Here Mudassar Ahmed Khan has explained with examples, how to use XPath with XmlDocument and how to select XML nodes by Name and Attribute value using XPath expression in C# and VB.Net.
0 Comments   1366 Views
Here Mudassar Ahmed Khan has explained a short article to clear a common doubt faced by developers i.e. what is the difference between small string and capital String data types in C# .Net.
0 Comments   965 Views
Here Mudassar Ahmed Khan has explained a short article to clear a common doubt faced by developers i.e. what is the difference between bool and Boolean data type in C# .Net.
0 Comments   1145 Views
Here Mudassar Ahmed Khan has explained with example, how to read binary data files and convert them to their respective file formats and write the files as binary data and save it to database.
Here Mudassar Ahmed Khan has explained how to convert / copy DataReader (SqlDataReader) data to DataTable and DataSet using C# and VB.Net.
The DataTable and DataSet will be populated with records from the DataReader using Load method of the DataTable.
Here Mudassar Ahmed Khan has explained how to call (consume) Web Service (ASMX) in Windows Forms (WinForms) application using C# and VB.Net.
Here Mudassar Ahmed Khan has explained how to call (consume) Web Service (ASMX) in Console application using C# and VB.Net.
1 Comments   1873 Views
Here Mudassar Ahmed Khan has explained how to send HTML Page (File) as Email Body in ASP.Net using C# and VB.Net.
0 Comments   2002 Views
Here Mudassar Ahmed Khan has explained how to attach a File from MemoryStream to MailMessage object and send as email attachment in ASP.Net using C# and VB.Net.
This article will explain how to attach a PDF file from MemoryStream to MailMessage object and send as email attachment in ASP.Net using C# and VB.Net.
0 Comments   728 Views
Here Mudassar Ahmed Khan has explained with an example, how to convert Byte Array to Base64 String using C# and VB.Net.
0 Comments   1372 Views
Here Mudassar Ahmed Khan has explained how to insert and retrieve images from SQL Server database without using Stored Procedures using C# and VB.Net.
Here Mudassar Ahmed Khan has explained with an example, how to populate (fill) DataTable and DataSet using DataReader (SqlDataReader) in C# and VB.Net.
The DataTable and DataSet will be populated with records from the DataReader using Load method of the DataTable.
0 Comments   838 Views
Here Mudassar Ahmed Khan has explained with an example, how to insert (save) to SQL Server Table in C# and VB.Net using the SQL Server User Defined Table Type.
0 Comments   287 Views
Here Mudassar Ahmed Khan has explained with an example, how to generate unique Random Strings containing Letters and Numbers (AlphaNumeric) and Numbers (Numeric) in ASP.Net using C# and VB.Net.
The unique Random Strings containing Letters and Numbers (AlphaNumeric) and Numbers (Numeric) will be generated in variable lengths such as 5, 8 and 10 characters in ASP.Net using C# and VB.Net.