11
Answers

insert a converted date into database

Mehboob Ali

Mehboob Ali

8y
427
1
 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)