Mehboob Ali

Mehboob Ali

  • NA
  • 25
  • 3k

insert a converted date into database

Feb 27 2016 10:19 PM
 My System date format is customized as dd/MM/yyyy
 
when i enter date e.g 25/02/2016 than in textbox c# windows form, it gives error System.Data.SqlClient.SqlException
 
 
My Code is given below 
 
private void button1_Click(object sender, EventArgs e)
{
SqlConnection con = new SqlConnection("Data Source=.;Initial Catalog=Test;User ID=abc; Password=****");
SqlDataAdapter sda = new SqlDataAdapter("insert into dates values('"+textBox1.Text.ToString()+"')",con);
DataTable dt = new DataTable();
sda.Fill(dt);
MessageBox.Show("Data Inserted");

Answers (11)