How do i insert current time in SQL Table???
What will be the query????
Printable View
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 sameQuote:
Originally Posted by planet_abhi
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();
}
Quote:
How do i insert current time in SQL Table???
What will be the query????
That's Oracle.Code:INSERT INTO YOUR_TABLE( YOUR_FIELD ) VALUES ( SYSDATE );
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