This is the working solution : Use any sql option but do not change the C# .
SQL OPTION 1 :
CREATE TABLE [dbo].[tempTable](
[List_Id] [int] NULL,
[Date] [datetime] NULL,
[Time] [datetime] NULL
) ON [PRIMARY]
GO
SQL OPTION 2 :
CREATE TABLE [dbo].[tempTable](
[List_Id] [int] NULL,
[Date] date NULL,
[Time] [datetime] NULL
) ON [PRIMARY]
GO
C# :
string query = "Insert into tempTable(List_Id, Date, Time) VALUES('" + lblId.Text + "', @Date, @Time)";
SqlCommand cmd = new SqlCommand(query, connection);
connection.Open();
TimeSpan time = new TimeSpan();
time.ToString();
cmd.Parameters.AddWithValue("@Date", Convert.ToDateTime(DateTime.Now.ToShortDateString()));
cmd.Parameters.AddWithValue("@Time", Convert.ToDateTime(DateTime.Now.ToString("HH:mm:ss")));
cmd.ExecuteNonQuery();
connection.Close();
NOTE :
To save only time in HH:mm format you will have to use nvarchar , which is a bad idea ... so save it the way i did , then when you are about to show the records in gridview at that time format it in gridview so it will show you the time in HH:mm:ss or HH:mm