Monday, 4 February 2013

ASP.Net Sent Email

Solutions 1:  
try
{
      using (System.Net.Mail.MailMessage message = new MailMessage())
     {
             message.To.Add(new MailAddress("To Email adddress"));
             message.CC.Add(new MailAddress("CC Email adddress"));
             message.Subject = " < Your Subject >"
             message.Body =" < Message>"
            SmtpClient client = new SmtpClient();
            client.Host = "smtp.gmail.com";  //gmail           
            client.Port = 587;
           client.Credentials = new System.Net.NetworkCredential("Sender Email", "Password");
           client.EnableSsl = true;
           client.Send(message);
    }
   Messagebox.show("Email sent Suessfully");
}
catch (Exception e)
{
      Messagebox.show(e.message);
}

Tuesday, 22 January 2013

String Format for Int [C#]

Solutions 1:  
Add zeroes before number
String.Format("{0:00000}", 15);          // "00015"
String.Format("{0:00000}", -15);         // "-00015"

Align number to the right or left
String.Format("{0,5}", 15);              // "   15"
String.Format("{0,-5}", 15);             // "15   "
String.Format("{0,5:000}", 15);          // "  015"
String.Format("{0,-5:000}", 15);         // "015  "

Different formatting for negative numbers and zero
String.Format("{0:#;minus #}", 15);      // "15"
String.Format("{0:#;minus #}", -15);     // "minus 15"
String.Format("{0:#;minus #;zero}", 0);  // "zero"


Custom number formatting (e.g. phone number)
tring.Format("{0:+### ### ### ###}", 447900123456); // "+447 900 123 456"
String.Format("{0:##-####-####}", 8958712551);       // "89-5871-2551"

String to Date to String in C#


Solutions 1:  

String to Date

DateTime Date = Convert.ToDateTime("1/22/2013 12:37:45 PM");

Date to String 

MessageBox.Show(Date.ToString("d"));    //     1/22/2013                 
MessageBox.Show(Date.ToString("D"));    //    Tuesday, January 22, 2013
MessageBox.Show(Date.ToString("U"));     //    Tuesday, January 22, 2013 12:37:45 PM
MessageBox.Show(Date.ToString("y"));    //    January, 2013
MessageBox.Show(String.Format("{0:ddd}",Date));  //Tue

MessageBox.Show(String.Format("{0:MM/dd/yyyy}",Date));  // 01/22/2013


String Format for DateTime [C#]

Friday, 28 December 2012

Find a folder with Visual Studio project

 In the Solution Explorer right-click on the solution name and select "Open folder in windows explorer"

Check internet connection

System.Net.WebClient   //Name space

Solutions 1:  
Public Void InternetConnCheck()
{     
     try
     { 
        WebClient Client=new WebClient ();
       Using (var stream = client.OpenRead("http://www.google.com")
       {       
           Messagebox.show("Connection is Open"); 
       }
     catch
     {
          Messagebox.show("Connection Not available");  
     }   

}

Solutions 2: 

Public Void InternetConnCheck()
{     
     try 
     {       
       System.Net.IPHostEntry i = System.Net.Dns.GetHostEntry("www.google.com");
               Messagebox.show("Connection available");        
     }
     catch
     { 
        Messagebox.show("Connection Not available"); 
     }  

}

Solutions 3: 
bool InternetConnection = new Ping().Send
                          ("www.google.co.in").Status == IPStatus.Success;

Thursday, 27 December 2012

Check database connection is open or close

Solutions 1: 
OledbConnString = "Provider=Microsoft.Jet.OLEDB.4.0; Data Source=C:\test.mdb";
OleDbConnection Conn = new OleDbConnection(OledbConnString);
if (Conn.State == Conn.Open)
{
     Messagebox.show("Connection is Open");
}
else
{
     Messagebox.show("Connection is Close");
}

Tuesday, 25 December 2012

How to install East Asian language in Windows XP without CD

Solutions 1:   
1.  Download East Asian Language pack and extract files to a local folder  
2. Go to Start menu
3. Click Run
4.  Type"intl.cpl" and click OK
5. Choose tab “Languages”
6. check the “Install files for East Asian languages".

7. Choose Extract File Path
8. Choose "XJIS.NL_"

9.  Reboot System
10.  Repeat step 2,3,4,5
11. Click button “Details”.


12.Click button “Add”

13. You will see “Add Input Language” dialogue box. Choose “Korean” from dropdownlist.
14. You will see in “Korean” language part, the keyboard part is now has “Korean”. 
15. Click on the language to choose different input. You will see there are two input services. KO for Korean, and EN for English. Choose “Korean”.