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!!!!!!!!!!!!

DateTime.Now().AddDays(15) assuming today is the issue date. Take a look at DateTime to see all the fun things you can do with it.

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

Put it where you have the 97 ? marks.

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 :)

Thanks i guess it works..
Hope it will not give any exception

Momerath is da Man, so there will surely wont be any exceptions, if only your other ocde runs fine :)

thanks...will due date comes automatically in read only textbox???

Be a part of the DaniWeb community

We're a friendly, industry-focused community of developers, IT pros, digital marketers, and technology enthusiasts meeting, networking, learning, and sharing knowledge.