SqlConnection conn = new SqlConnection(ConfigurationSettings.AppSettings["ConnectionString"]); string strConn = "Data Source=USER-PC;Initial Catalog=PIWCDB;User ID=sa;Password=mike"; string strSQL = "select Dedicationid, Surname, Othername from tblDedication where surname LIKE '" + txtSurname.Text + "%" + "' order by Surname"; //conn.Open(); SqlDataAdapter dataAdapter = new SqlDataAdapter(strSQL, strConn); SqlCommandBuilder commandBuilder = new SqlCommandBuilder(dataAdapter); // Populate a new data table and bind it to the BindingSource. DataTable table = new DataTable(); table.Locale = System.Globalization.CultureInfo.InvariantCulture; dataAdapter.Fill(table); string expression = "[Dedicationid] like '%" + this.txtDedicationno.Text + "%'"; DataRow[] filteredRows = table.Select(expression); if (filteredRows.Any()) { table = filteredRows.CopyToDataTable(); this.dgvSearchname.Visible = true; this.dgvSearchname.BringToFront(); } else { dgvSearchname.Visible = false; } // you can make it grid readonly. dgvSearchname.ReadOnly = true; dgvSearchname.DataSource = table;
var
This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)