hi
Please Experts Check this program
Data does not showing in gridvew from database when i am selecting the date in the datetimepicker.
Not Working
string connstr = @"Server=.\SQLEXPRESS ;Initial Catalog=RPSJDB;Integrated Security=True; Max Pool Size=100";
string query = "select txtDate,txtCustomerName,txtAddress from EntryTable where txtDate=@myDate";
SqlConnection conn = new SqlConnection(connstr);
SqlDataAdapter dataAdapter = new SqlDataAdapter(query, conn);
dataAdapter.SelectCommand.Parameters.Add("@myDate", dateTimePicker1.Value);
SqlCommandBuilder commandBuilder = new SqlCommandBuilder(dataAdapter);
DataTable table = new DataTable();
table.Locale = System.Globalization.CultureInfo.InvariantCulture;
dataAdapter.Fill(table);
dataGridView1.DataSource = table;
bindingSource1.DataSource = table;
dataGridView1.AutoResizeColumns(DataGridViewAutoSizeColumnsMode.AllCellsExceptHeader);
dataGridView1.ReadOnly = true;
dataGridView1.DataSource = bindingSource1;
Working
string connstr = @"Server=.\SQLEXPRESS ;Initial Catalog=RPSJDB;Integrated Security=True; Max Pool Size=100";
string query = "select txtDate,txtCustomerName,txtAddress from EntryTable where txtCustomerName='Manish'";
SqlConnection conn = new SqlConnection(connstr);
SqlDataAdapter dataAdapter = new SqlDataAdapter(query, conn);
DateTime tempDateTime = new DateTime();
SqlCommandBuilder commandBuilder = new SqlCommandBuilder(dataAdapter);
DataTable table = new DataTable();
table.Locale = System.Globalization.CultureInfo.InvariantCulture;
dataAdapter.Fill(table);
dataGridView1.DataSource = table;
bindingSource1.DataSource = table;
dataGridView1.AutoResizeColumns(DataGridViewAutoSizeColumnsMode.AllCellsExceptHeader);
dataGridView1.ReadOnly = true;
dataGridView1.DataSource = bindingSource1;