Category Archives: Technology

How to check if directory exists in specified path and then create directory

By | 20th November 2017

The following code illustrates on how to check if directory exists in specific path, if not then create directory. Here I show that how to create the directory with simple condition.     private void TestDirectory() {     string pathname = “C:\\Myfolder”;         if(!Directory.Exists(pathname)) {     Directory.CreateDirectory(pathname); } }  

How to copy or duplicate the structure and data of table in the database in MySql

By | 26th September 2017

If you need the similar structure of the table with different tablename, it’s better to duplicate r copy the table structure than creating a new table from scratch. It is easy to duplicate the table structure and rename it. Select any database table and right click and click on the option Duplicate Table Structure /Data… Read More »

How to extract data to Microsoft Excel Sheet from database

By | 23rd September 2017

  1.Declaration MX.Application xl = null; MX.Workbook wb = null; MX.Worksheet wsheet = null; xl = new MX.Application(); wb = Microsoft.Office.Interop.Excel.Workbook)(xl.Workbooks.Add(Missing.Value)); wb.Sheets.Add(Missing.Value, Missing.Value, Missing.Value, Missing.Value); wsheet = (Microsoft.Office.Interop.Excel.Worksheet)(wb.Sheets[1]); wsheet.Cells.Font.Name = “VERDANA”; wsheet.Cells.Font.Size = 9; wsheet.Cells.HorizontalAlignment = MX.XlHAlign.xlHAlignCenter; wsheet.get_Range(“A1”, “A1”).ColumnWidth = 9; wsheet.get_Range(“B1”, “B1”).ColumnWidth = 13; wsheet.get_Range(“C1”, “C1”).ColumnWidth = 28; wsheet.get_Range(“D1”, “D1”).ColumnWidth = 12; wsheet.Cells[4, 1]… Read More »

How to use insert query statement in Mysql

By | 13th September 2017

Insert query is used to add/insert the data values into the database tables. By executing the query the data easily inserts into the database. The below statement is how we actually insert the data values into the database.   cmd.CommandText = “insert into `databasename.tablename (field1,field2) values (‘1′,’abc’); cmd.Connection = con; cmd.ExecuteNonQuery(); How to use alter… Read More »

How to use BackgroundWorker in C#.Net

By | 9th September 2017

BackgroundWorker in C# is used to simplify threading. This object is designed to simply run a function on a different thread and then call an event on your UI thread when it’s complete.   Illustration code: 1. backgroundWorker1.RunWorkerAsync() :  Used to kickoff the worker thread to begin it’s DoWork function.       private void button1_Click(object sender, EventArgs… Read More »