C Board  

Go Back   C Board > General Programming Boards > C# Programming

Reply
 
LinkBack Thread Tools Display Modes
Old 11-14-2005, 05:31 AM   #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
planet_abhi is offline   Reply With Quote
Old 11-14-2005, 07:44 AM   #2
&TH of undefined behavior
 
Fordy's Avatar
 
Join Date: Aug 2001
Posts: 5,215
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();
}
__________________
"If A is success in life, then A equals x plus y plus z. Work is x; y is play; and z is keeping your mouth shut."
Albert Einstein (1879 - 1955)


Board Rules
Fordy is offline   Reply With Quote
Old 11-14-2005, 09:20 AM   #3
the hat of redundancy hat
 
nvoigt's Avatar
 
Join Date: Aug 2001
Location: Hannover, Germany
Posts: 2,769
Quote:
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.
nvoigt is offline   Reply With Quote
Old 11-15-2005, 10:49 PM   #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
nickname_changed is offline   Reply With Quote
Reply

Thread Tools
Display Modes

Forum Jump

Similar Threads
Thread Thread Starter Forum Replies Last Post
How to get current time tsubasa C Programming 3 05-01-2009 02:03 AM
How to improve time performance of these operations lehe C Programming 11 03-29-2009 12:27 PM
Help with assignment! RVDFan85 C++ Programming 12 12-03-2006 12:46 AM
calculating user time and time elapsed Neildadon C++ Programming 0 02-10-2003 06:00 PM
time class Unregistered C++ Programming 1 12-11-2001 10:12 PM


All times are GMT -6. The time now is 02:31 PM.


Powered by vBulletin® Version 3.8.1
Copyright ©2000 - 2010, Jelsoft Enterprises Ltd.
Search Engine Optimization by vBSEO 3.3.2

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