Skip to main content

Posts

Showing posts from 2013

How do I make a textbox that only accepts numbers?

How do I make a textbox that only accepts numbers? private void textBox1_KeyPress( object sender, KeyPressEventArgs e) {     if (! char . IsControl (e. KeyChar )         && ! char . IsDigit (e. KeyChar )         && e. KeyChar != '.' )     {         e. Handled = true ;     }     // only allow one decimal point     if (e. KeyChar == '.'         && (sender as TextBox ). Text . IndexOf ( '.' ) > - 1 )     {         e. Handled = true ;     } } Or use this  private void textBox1_TextChanged ( object sender , EventArgs e )     {         if ( System . Text . RegularExpressions . Regex . IsMatch ( "[^0-9]" , textBox1 . Text ))         {             MessageBox . Show ( "Please enter only numbers." );             textBox1 . Text . Remove ( textBox1 . Text . Length - 1 );         }     }

Happy Diwaly

Happy Diwali to all All

How to read Password Field

          How to read Password From Website              Right-click the password box and select "Inspect Element." This brings up the developer console. On the line that starts with "input type=password" change the word "password" to "text." This will reveal your password. While you can always pop into your browsers menu screen to look up saved passwords (or into your LastPass profile), this is a far quicker way to see your hidden passwords. Thanx for read this Article..

SQL Server CONVERT() Function

SQL Server  CONVERT()  Function The CONVERT() function is a general function that converts an expression of one data type to another. The CONVERT() function can be used to display date/time data in different formats. Syntax CONVERT( data_type(length) , expression , style ) Example The following script uses the CONVERT() function to display different formats. We will use the GETDATE() function to get the current date/time: CONVERT(VARCHAR(19),GETDATE()) CONVERT(VARCHAR(10),GETDATE(),10) CONVERT(VARCHAR(10),GETDATE(),110) CONVERT(VARCHAR(11),GETDATE(),6) CONVERT(VARCHAR(11),GETDATE(),106) CONVERT(VARCHAR(24),GETDATE(),113) The result would look something like this: Nov 04 2011 11:45 PM 11-04-11 11-04-2011 04 Nov 11 04 Nov 2011 04 Nov 2011 11:45:34:243

How to Genrate XML file in C#

How to Genrate XML file in C# Create File xmldocument doc=new xmldocument(); doc.save(@"c:/program files/file name/add.xml"); ADD Attributes And Save XmlDocument XD = new XmlDocument(); XmlNode Root = XD.AppendChild(XD.CreateElement("Root")); XmlNode Child = Root.AppendChild(XD.CreateElement("Child")); XmlAttribute ChildAtt =Child.Attributes.Append(XD.CreateAttribute("Attribute")); ChildAtt.InnerText = "My innertext"; Child.InnerText = "Node Innertext"; XD.Save("Add.xml"); Example using System; using System.Xml;   public class GenerateXml { private static void Main() { XmlDocument doc = new XmlDocument(); XmlNode docNode = doc.CreateXmlDeclaration("1.0", "UTF-8", null); doc.AppendChild(docNode);   XmlNode productsNode = doc.CreateElement("products"); doc.AppendChild(productsNode);   XmlNode productNode = doc.CreateElement("prod

How to Get Server name, Database name, User name, Password from web.config file in C#

How to Get Server name, Database name, User name, Password from web.config file in C#  System.Data.Common.DbConnectionStringBuilder builder = new System.Data.Common.DbConnectionStringBuilder(); builder.ConnectionString = ConfigurationManager.ConnectionStrings["inventoryDBConnection"].ConnectionString; ; string server = builder["Data Source"] as string; string database = builder["Initial Catalog"] as string; string UserID = builder["User ID"] as string; string password = builder["Password"] as string; Thanks For read this Article

How to get First,Last,Next,Previews Data in .Net C#

using System; using System.Collections.Generic; using System.ComponentModel; using System.Data; using System.Drawing; using System.Text; using System.Windows.Forms; using System.Data.Odbc; using System.IO; namespace WindowsApplication1 {     public partial class Form1 : Form     {         public Form1()         {             InitializeComponent();         }         OdbcDataAdapter da;         DataSet ds;         int i = 0;         int j;         OdbcConnection conn;         int last;         private void Form1_Load( object sender, EventArgs e)         {             conn = new OdbcConnection ( "dsn=t1" );             conn.Open();             da = new OdbcDataAdapter ( "select * from emp" , conn);             OdbcCommandBuilder builder = new OdbcCommandBuilder (da);             ds = new DataSet ();             da.Fill(ds, "emp" );             dataGridView1.DataSource = ds.Tabl