16 December 2008

C# MS Access Connection String OLE DB OleDbConnection

The Connection String for MS Access can be set as ;
 private constr =
"Provider=Microsoft.Jet.OLEDB.4.0;Data Source=yourdbfile.mdb;
Jet OLEDB:Database Password=yourpassword;";
And the C# code to connect to MS Access database ;
 public bool OpenConnection()
{
OleDbConnection con; con = new OleDbConnection(constr);

if (con.State != ConnectionState.Open)
{
try
{
con.Open(); return true;
}
catch (Exception) { return false; }
}
else return false;
}
C# Access Connection String OLE DB OleDbConnection password field is the password you set up in access database.

Mobile Phone Hide Your Number

To hide your number when you are calling someone with your mobile phone,
simply add *31# in the beginning of the number you will call.

hide number
*31#

Imei Number Learn Your Mobile Phone Imei Number

You can easily learn you mobile phone's IMEI number
by pressing star square 06 square

*#06#

11 December 2008

C# Read Harddisk Serial Number WMI ManagementClass Win32_LogicalDisk

With the Win32_LogicalDisk Management path we can reach the local disk information.

Even you can read harddisk serial number,
size, partitions, free space and so on.

Now let's read the serial number of a harddisk in C# with ManagementClass WMI.
public static string HardDiskID()
{
ManagementClass partionsClass = new ManagementClass("Win32_LogicalDisk");
ManagementObjectCollection partions = partionsClass.GetInstances();

string hdd = string.Empty;

foreach (ManagementObject partion in partions)
{
hdd = Convert.ToString(partion["VolumeSerialNumber"]);

if (hdd != string.Empty)
return hdd;
}

return hdd;
}
This static function will simple give us the volume serial numbers.
C# Read Harddisk Serial Number WMI ManagementClass.