I have created a database to save details of online-exam generation.
Here i want to save duration of exam time and i am using datetime datatype for this, but it takes current date also which is not needed.
...below is my table structure...
create table Exams
(
slNo int primary key identity(1,1),
examID varchar(10) unique not null,
title varchar(500) not null,
examHours datetime not null,
totalQn integer not null,
totalMarks integer not null
);
The user inputs the time in three textboxes in format txtHH , txtmm , and txtSS respectively.
here is codebehind page...
SqlConnection con = GlobalConnect.FnConnection();
con.Open();
string exmTime = string.Format(txtHH.Text.ToString() + ":" + txtMM.Text.ToString() + ":" + txtSS.Text.ToString());
SqlCommand cmd = new SqlCommand("Insert into dbo.Exams(examID,title,examHours,totalQn,totalMarks) values(@examID,@title,@examHours,@totalQn,@totalMarks)");
cmd.Parameters.AddWithValue("@examID", lblExmId.Text);
cmd.Parameters.AddWithValue("@title", txtTitle.Text.Trim());
cmd.Parameters.AddWithValue("@examHours",Convert.ToDateTime( exmTime));
cmd.Parameters.AddWithValue("@totalQn", TxtNoOfQn.Text.Trim());
cmd.Parameters.AddWithValue("@totalMarks", TxtTotMarks.Text.Trim());
int effect = GlobalConnect.ExecuteNonQuery(cmd);
Please suggest me how to do this.