Reading and Writing Values From/Into Windows Registry

Here is the code for read the registry value using C#.
First I’m creating registry key value and string value in local machine as follows,
myKey –> key value
myValue –> string name
myReturnValue –> string value
Code for Registry value Reading using C#…
using Microsoft.Win32;
try
{
RegistryKey registry = Registry.LocalMachine.CreateSubKey(”SOFTWARE\\myKey”);
if (registry != null)
{
MessageBox.Show(registry.GetValue(”myValue”));
registry.Close();
}
}
catch (Exception ex)
{
MessageBox.Show (ex.ToString());
}
 
Code for Values writing in Registry using [...]

Using MS Excel in C# as a Database

Use the code below to retrieve data from EXCEL sheet in C#
An openfiledialog box control has been usedd to get the excel file.
excel.sheetname gives the name of the sheet in the excel file.
exceldetail.col and exceldetail.col1 have been use for column in excel sheet.

if (openFileDialog1.ShowDialog() == DialogResult.OK)
{
string ConnectionString = @”Provider=Microsoft.Jet.OLEDB.4.0;Data Source=” + openFileDialog1.FileName.ToString() + “;Extended Properties=\”Excel [...]

C# Code : Implementing MS-ACCESS Database

Code for Retrieving Values from Access Database

try
{
OleDbConnection thisConnection = new OleDbConnection(@”Provider=Microsoft.Jet.OLEDB.4.0;Data Source=C:\Program Files\Hash-Tech\Hash Reminder Setup\Hash Reminder.mdb”);
thisConnection.Open();
OleDbDataAdapter adp = new OleDbDataAdapter(”Select * from ReminderTable”, thisConnection);
OleDbCommandBuilder cmd = new OleDbCommandBuilder(adp);
DataSet ds = new DataSet(”ReminderTable”);
adp.Fill(ds, “ReminderTable”);
DataRow dr = ds.Tables["ReminderTable"].NewRow();
dr["SetDate"] = setdateinp;
dr["SetTime"] = settimeinp;
dr["ReminderType"] = remtypeinp;
dr["ReminderHead"] = remheadinp;
dr["ReminderText"] = remtextinp;
dr["EndDate"] = enddateinp;
dr["EndTime"] = endtimeinp;
dr["Status"] = “Progress”;
ds.Tables["ReminderTable"].Rows.Add(dr);
adp.Update(ds, “ReminderTable”);
thisConnection.Close();
}
catch (Exception z)
{
MessageBox.Show(”Error” [...]

Creating the Outlook CSV Files from your Datagrid View

The CSV files are files containing the values seperated by comma. These files are generally used to store contact Details becuase they are very much acceptable across different mail client and websites. Here i am writing code to craete a CSV file from the Data containe in the Datagrid View.
DatagridView Name = dataGridView1
File Created at [...]

Integrating SQL database within the .NET project

Many of you have had develope applications that use the database for a proper functioning, the main problem comes when you consider to eploy you application at any other machine. The Database is not available at the machine, so your application gives error. To remove this error, there are two ways you create the database [...]

Using ADO.NET Entity Framework effectively to enhance Efficiency of your Appliaction

Often developers need to understand the database before they can write access codes for it. Understanding complex database structure that is controlled by administrator becomes a bottleneck in application development cycle. Using Microsoft’s ADO.NET Entity Framework, developers can create an entity relationship model of the database (ie SQL Server) inside Visual Studio 2008. This conceptual [...]

Counting Number of Working Days in a Specified Month

The code written blow counts the number of working days in a specified month of the year.
Working Days means days excluding saturday and sunday.
The code is sample for Calculatng the No. of Working days in th current month.
double hrs = 24;  
int  num = 0; 
DateTime date = DateTime .Now; 
int month = date.Month; 
int year = date.Year; 
int max = [...]