date converstion error?
i m using below code
try
{
string date = System.DateTime.Now.ToString();
string bdate = Convert.ToDateTime(TextBox3.Text).ToString("yyyy-MM-dd");
string str;
string g;
g = "";
if (RadioButton1.Checked == true)
{
g = "Male";
}
else
{
g = "Female";
}
FileUpload img = (FileUpload)imgUpload;
Byte[] imgByte = null;
if (img.HasFile && img.PostedFile != null)
{
HttpPostedFile File = imgUpload.PostedFile;
imgByte = new Byte[File.ContentLength];
File.InputStream.Read(imgByte, 0, File.ContentLength);
}
str = "insert into Student values('" + txtName.Text + "','"+bdate.ToString() + "','" + g.ToString() + "','" + txtAddress.Text + "'," + ddlstate.SelectedValue + "," + ddlcity.SelectedValue + ",'" + DropDownList1.SelectedItem.Text + "','" + txtUserName.Text + "','" + TextBox1.Text + "','" + DropDownList2.SelectedItem.Text + "','" + DropDownList3.SelectedItem.Text + "','" + TextBox7.Text + "','"+imgByte.ToString()+"','" + date + "','false')";
Int64 i;
i = ObjConn.ExecuteNonQuery(str);
if
(i > 0)
{
Label1.Text = "Record Inserted Successfully!!!";
Label1.ForeColor = System.Drawing.Color.Green;
txtName.Text = "";
TextBox3.Text = "";
RadioButton1.Checked = false;
RadioButton2.Checked = false;
txtAddress.Text = "";
txtUserName.Text = "";
TextBox1.Text = "";
TextBox7.Text = "";
}
else
{
Label1.Text = "Error while Inserting data!!!";
Label1.ForeColor = System.Drawing.Color.Red;
}
}
catch(Exception ex)
{
throw ex;
}