String not recognized as a valid Date

protected void Button1_Click(object sender, EventArgs e) { con.Open(); if (enrl.Text == "") { Label1.Text = "Enter Enrollment Number first"; } int enroll = int.Parse(enrl.Text); string birth = Convert.ToDateTime(calendar.Text).ToShortDateString(); string fullname = name.Text; string father = fname.Text; string Occ = fOcc.Text; string mname = mothername.Text; string school = prevschool.Text; string gen = dropGen.Text; int mobile = int.Parse(mob.Text); string mail = email.Text; string rel = DropRelgn.Text; //string adm = Convert.ToDateTime(admDate.Text).ToShortDateString(); string facility = hostel.Text; string ad = address.Text; cmd.CommandText = "insert into Registration_N(enroll,FullName,AdmissionDT,DOB,Religion,Gender,Father,FOccup,address,Mobile,dayHostel,previousSchool,motherName,email) values (" + enroll + ",'" + fullname + "','" + adm + "', '" + birth + "' , "+rel+","+father+" , "+fOcc+","+ad+",'"+mobile+"',"+hostel+","+prevschool+","+mname+","+email+")"; cmd.ExecuteNonQuery(); da.Update(ds,"Registration_N"); Label1.Text = "RECORD ADDED"; con.Close(); }

-------------Problems Reply------------

check what is the format the your sql server expect to get (e.g MM/dd/yyyy) and what the format your code result is (e.g. dd/MM/yyyy)

Category:c# Views:7 Time:2018-12-09

Related post

Copyright (C) dskims.com, All Rights Reserved.

processed in 0.217 (s). 12 q(s)