Time?????

This is a discussion on Time????? within the C# Programming forums, part of the General Programming Boards category; How do i insert current time in SQL Table??? What will be the query????...

  1. #1
    Registered User planet_abhi's Avatar
    Join Date
    Oct 2002
    Posts
    92

    Time?????

    How do i insert current time in SQL Table???
    What will be the query????
    AbHHinaay

  2. #2
    &TH of undefined behavior Fordy's Avatar
    Join Date
    Aug 2001
    Posts
    5,789
    Quote Originally Posted by planet_abhi
    How do i insert current time in SQL Table???
    What will be the query????
    The SQL and the objects used are for MySQL, but the principal should be the same

    Code:
    string UpdateString = "INSERT INTO SomeTable (DateField) VALUES (?DateField)";
    
    
    MySqlConnection oCon = null;
    MySqlCommand oCom = null;
    try
    {
    	oCon = new MySqlConnection();
    	oCon.ConnectionString = 
    		ConfigurationSettings.AppSettings["ConnectionString"];
    	oCon.Open();
    	oCom = new MySqlCommand();
    	oCom.Connection = oCon;
    				
    	oCom.CommandText = UpdateString;
    						
    	oCom.Parameters.Add("?DateField", DateTime.Parse("01/01/1950"));	
    					
    	oCom.ExecuteNonQuery();
    finally
    {
    	if(oCon != null)
    		oCon.Close();
    }

  3. #3
    the hat of redundancy hat nvoigt's Avatar
    Join Date
    Aug 2001
    Location
    Hannover, Germany
    Posts
    3,139
    How do i insert current time in SQL Table???
    What will be the query????
    Code:
    INSERT INTO YOUR_TABLE( YOUR_FIELD ) VALUES ( SYSDATE );
    That's Oracle.
    hth
    -nv

    She was so Blonde, she spent 20 minutes looking at the orange juice can because it said "Concentrate."

    When in doubt, read the FAQ.
    Then ask a smart question.

  4. #4
    Banned nickname_changed's Avatar
    Join Date
    Feb 2003
    Location
    Australia
    Posts
    986
    INSERT INTO myTable ([ADateColumn], [ATextColumn]) VALUES (getdate(), 'Paul Rocks')

    Is the SQL Server query.

    To execute the query, start here:

    http://msdn.microsoft.com/library/de...ClassTopic.asp

Popular pages Recent additions subscribe to a feed

Similar Threads

  1. How to get current time
    By tsubasa in forum C Programming
    Replies: 3
    Last Post: 05-01-2009, 02:03 AM
  2. Replies: 11
    Last Post: 03-29-2009, 12:27 PM
  3. Help with assignment!
    By RVDFan85 in forum C++ Programming
    Replies: 12
    Last Post: 12-02-2006, 11:46 PM
  4. calculating user time and time elapsed
    By Neildadon in forum C++ Programming
    Replies: 0
    Last Post: 02-10-2003, 05:00 PM
  5. time class
    By Unregistered in forum C++ Programming
    Replies: 1
    Last Post: 12-11-2001, 09:12 PM

1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21