Bulk Inserting data into MySQL From C#.net

Hey Friends,

I think you have used bulk insert into MS SQL database, Here is an example for Bulk inserting data into MySQL database

First you need to add MySql.Data.dll which can be easily downloaded from http://dev.mysql.com/downloads/connector/net/1.0.html, This library is .net connector for MySQL.

Source code, table structure and the stored procedure are added follows..

Source Code:

public void BulkCopyCTC(List<EmployeeDet> list)
        DataTable dt =new DataTable();
        dt.Columns.Add(new DataColumn("employee_id",typeof(System.String)));
        dt.Columns.Add(new DataColumn("employee_name",typeof(System.String)));
        dt.Columns.Add(new DataColumn("emp_ctc",typeof(System.Decimal)));

        foreach(EmployeeDet item in list)
            DataRow dr = dt.NewRow();
            dr["employee_id"]= item.GetID();
            dr["employee_name"]= item.GetName();
            dr["emp_ctc"]= item.GetCTC();

        MySqlConnection con =new MySqlConnection(newConnectionUtils().GetConnectionString());
        MySqlCommand cmd =new MySqlCommand("SP_InsertCTC", con);


        cmd.Parameters.Add("?e_name",MySqlDbType.String).SourceColumn=  "employee_name";
        cmd.Parameters.Add("?emp_ctc",MySqlDbType.Decimal).SourceColumn=  "emp_ctc";  

        MySqlDataAdapter da =new MySqlDataAdapter();
        da.InsertCommand= cmd;
        int records = da.Update(dt);

Table Structure :

CREATE TABLE `employee_ctc` (
        `emp_id` VARCHAR(20) NULL DEFAULT NULL,
        `emp_name` VARCHAR(50) NULL DEFAULT NULL,

Stored Procedure:

CREATE DEFINER=`root`@`localhost` PROCEDURE `SP_InsertCTC`(e_id VARCHAR(20),e_name VARCHAR(50),emp_ctc DECIMAL(10,2))
        INSERT INTO Employee_CTC(emp_id,emp_name,CTC) VALUES(emp_id,emp_name,emp_CTC);

Universal transistor serves as a basis to perform any logic function

Most of today’s electronics devices contain two different types of field-effect transistors (FETs): n-type (which use electrons as the charge carrier) and p-type (which use holes). Generally, a transistor can only be one type or the other, but not both. Now in a new study, researchers have designed a transistor that can reconfigure itself as either n-type or p-type when programmed by an electric signal. A set of these “universal transistors” can, in principle, perform any Boolean logic operation, meaning circuits could perform the same number of logic functions with fewer transistors. This advantage could lead to more compact hardware and novel circuit designs.


For More Details  Visit: http://www.physorg.com/news/2011-12-universal-transistor-basis-logic-function.html

PHP: Loop through dates (from date to date) with strtotime() function

This is very easy way loop through dates (from date to date) with PHP strtotime() function. This example only echo dates, but of course this model can be used more complicated situations.


	// Set timezone

	// Start date
	$date = '2009-12-06';
	// End date
	$end_date = '2020-12-31';

	while (strtotime($date) <= strtotime($end_date)) {
		echo "$date\n";
		$date = date ("Y-m-d", strtotime("+1 day", strtotime($date)));


Join date and time fields

I genuinely don’t know how often this comes up for others but I came upon an occasion where I needed to be able to combine date and time fields, which were stored separately within a MySQL database, into a single datetime field.

In my case I had a “date” field, a “time” field (which were both populated) and an empty “full_datetime” field which was NULL and needed populating.

UPDATE myTable

SET full_datetime = CONCAT(`date`, ‘ ‘, `time`)


try if you need