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();
}