i want due date comes automatically as by adding after 15 days from date of issue.................

private void btnIssueBk_Click(object sender, EventArgs e)
{

SqlConnection cs = new SqlConnection("Data Source=IRIS-CSG-174;Initial Catalog=library_system;Integrated Security=True");
SqlDataAdapter da = new SqlDataAdapter();
cs.Open();
da.InsertCommand = new SqlCommand("Insert into Lib_issue_details Values(@book_tag_id,@member_id,@book_issue_on,@book_due_date)", cs);
da.InsertCommand.Parameters.Add("@book_tag_id", SqlDbType.VarChar).Value = textBox2.Text;
[B]da.InsertCommand.Parameters.Add("@member_id", SqlDbType.VarChar).Value = textBox3.Text;

da.InsertCommand.Parameters.Add("@book_issue_on", SqlDbType.DateTime).Value = Convert.ToDateTime(textBox4.Text);
da.InsertCommand.Parameters.Add("@book_due_date", SqlDbType.DateTime).Value=??????????????????????????????????
[/B]
DataSet ds = new DataSet();
DataTable dt = new DataTable();
//textBox4.Text = dt.AddDays(15).ToString();
textBox5.DataBindings.Add(new Binding("Text", ds, "issue_details.due_date"));
da.InsertCommand.ExecuteNonQuery();

what code i add to get due date automatically........... suggest me the correct code for it!!!!!!!!!!!!

thanks for the reply..!!!
can u plzz help me in the above code,,,as where to add this code

okk...thanks but i m not taking the current date...see my code line above ???...
actually i tried everthing but i m not getting it....!!!!

Replace this code

da.InsertCommand.Parameters.Add("@book_issue_on", SqlDbType.DateTime).Value = Convert.ToDateTime(textBox4.Text);
da.InsertCommand.Parameters.Add("@book_due_date", SqlDbType.DateTime).Value=??????????????????????????????????

With

DateTime myDateTime = Convert.ToDateTime(textBox4.Text);
da.InsertCommand.Parameters.Add("@book_issue_on", SqlDbType.DateTime).Value = myDateTime;
da.InsertCommand.Parameters.Add("@book_due_date", SqlDbType.DateTime).Value = myDateTime.AddDays(15);

There is no error checking here, so if textBox4 doesn't contain a date, you'll have problems :)

Edited 5 Years Ago by Momerath: n/a

This article has been dead for over six months. Start a new discussion instead.