hello mudassar sir while i was using your solution i encountered the following error
Compiler Error Message: CS0246: The type or namespace name 'CultureInfo' could not be found (are you missing a using directive or an assembly reference?)
Source Error:
|
Line 22: {
Line 23: DateTime dt1 = Convert.ToDateTime(TextBox3.Text);
Line 24: DateTime dt2 = Convert.ToDateTime(this.TextBox4.Text, new CultureInfo("en-GB"));
|
sir when i use only textbox3 the code runs properly and data inserted
protected void Page_Load(object sender, EventArgs e)
{
TextBox3.Text = DateTime.Now.ToString("dd/MM/yyyy");
TextBox4.Text = DateTime.Now.AddDays(10).ToString("dd/MM/yyyy");
}
protected void Button1_Click(object sender, EventArgs e)
{
//DateTime dt1 = Convert.ToDateTime(TextBox3.Text);
//DateTime dt2 = Convert.ToDateTime(this.TextBox4.Text, new CultureInfo("en-GB"));
SqlCommand cmd = new SqlCommand("rent_data", con);
cmd.CommandType = CommandType.StoredProcedure;
cmd.Parameters.AddWithValue("@member_id", TextBox1.Text);
cmd.Parameters.AddWithValue("@isbn", TextBox2.Text);
cmd.Parameters.AddWithValue("@issue_date",TextBox3.Text);
sir when i try to use the value of textbox4.text=DateTime.Now.AddDays(10).ToString("dd/MM/yyyy");
it display error Error converting data type nvarchar to datetime.
protected void Page_Load(object sender, EventArgs e)
{
TextBox3.Text = DateTime.Now.ToString("dd/MM/yyyy");
TextBox4.Text = DateTime.Now.AddDays(10).ToString("dd/MM/yyyy");
}
protected void Button1_Click(object sender, EventArgs e)
{
//DateTime dt1 = Convert.ToDateTime(TextBox3.Text);
//DateTime dt2 = Convert.ToDateTime(this.TextBox4.Text, new CultureInfo("en-GB"));
SqlCommand cmd = new SqlCommand("rent_data", con);
cmd.CommandType = CommandType.StoredProcedure;
cmd.Parameters.AddWithValue("@member_id", TextBox1.Text);
cmd.Parameters.AddWithValue("@isbn", TextBox2.Text);
cmd.Parameters.AddWithValue("@issue_date",TextBox3.Text);
cmd.Parameters.AddWithValue("@due_date",TextBox4.Text);