Import CSV to sql from asp.net c#

Here I will show how to Import data from csv file to sql database or any other database.
//This is the connection string to connect to your csv file
string strConString = “Provider=Microsoft.Jet.OLEDB.4.0;Data Source=c:\\; Extended Properties=\”Text;HDR=YES;\””;
// open connection
OleDbConnection oCon = new OleDbConnection(strConString);
oCon.Open();
// fill data set
string strSql = “SELECT * FROM csvfile.csv”; //csvfile should be present in c:
OleDbDataAdapter [...]

- Fetch XML (xmldatadocument) from database

This post shows you how to return XmlDataDocument from the database.
This helps you to fetch the xml data created in sql and use in asp.net.
If you are familiar how to get xml data from sql then this post helps you to fetch the xml data in XmlDataDocument.
//Code Starts Here
// http://helpindotnet.blogspot.com/
// http://helpindotnet.wordpress.com
public XmlDataDocument getauditnames(string prefixText, int [...]

- GZIP Compress a file using Asp.net and C#.

<span style=”font-weight:bold;”>Here I will show you the easiest way to compress and Decompress (Gzip) a file using Asp.net with c#.
You can compress any file with this method.</span>
//Code Starts here
using System;
using System.Collections.Generic;
using System.Text;
using System.IO;
using System.IO.Compression;
/*
* http://helpindotnet.blogspot.com/
*/
namespace ConsoleApplication1
{
class GZipTest
{
private const int buffer_size = 100;
public static int ReadAllBytesFromStream(Stream stream, byte[] buffer)
{
// Use this method is used to read [...]

- Send mail using System.Net..Mail

<span style=”font-weight:bold;”>Send Mail Messages Using System.Net.Mail namespace (new in .net Framework Version 2.0) which provides classes that enable you to easily create and transmit e-mail messages.</span>
Asp.net c#:
// Create a MailMessage object
MailMessage mm = new MailMessage();
// Define the sender and recipient
mm.From = new MailAddress(fromEmailAddress.Text, fromDisplayName.Text);
mm.To.Add(new MailAddress(toEmailAddress.Text, toDisplayName.Text));
// Define the subject and body
mm.Subject = subjectTextBox.Text;
mm.Body = bodyTextBox.Text;
mm.IsBodyHtml [...]