I have declared the datatyp of 'p_date' as datetime
I have also used DateTextBox_CalenderExtender on textbox.(from Ajax ToolKit)

DateTime datetime=new DateTime();
datetime=convert.ToDateTime(DateTextBox.text);
InsertIntoMrNo(mrNoTextBox.Text, datetime, postIdTextBox.Text);

 public void InsertIntoMrNo(string mrno, DateTime mrdate, string postid)
    {      
 connection =ConfigurationManager.AppSettings["ConnectionString"];
sqlConnectionObj = new SqlConnection(connection);
insertQuery = @"INSERT INTO mrno (mr_no,p_date,post_id) 
 VALUES('" + mrno+"',    '" + mrdate + "' ,'" + postid + "')";
sqlConnectionObj.Open();
sqlCommandObj = new SqlCommand(insertQuery, sqlConnectionObj);
sqlCommandObj.ExecuteNonQuery();
        }

error message is :The conversion of a char data type to a datetime data type resulted in an out-of-range datetime value. The statement has been terminated.
Please help.
Thanks to all...............

You need to format the date as desired before inserting the same into Database.

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.