private void BindGridForExcel() { try { OleDbConnection theConnection = new OleDbConnection("provider=Microsoft.ACE.OLEDB.12.0;data source=D:\\DotNet\\Copy of Depreciation working Oct-13.xlsx ;Extended Properties=\"Excel 8.0;HDR=NO;IMEX=1;\""); theConnection.Open(); OleDbDataAdapter theDataAdapter = new OleDbDataAdapter("SELECT * FROM [Working$]", theConnection); DataSet theDS = new DataSet(); DataTable dt = new DataTable(); theDataAdapter.Fill(dt); this.dataGridView1.DataSource = dt.DefaultView; theConnection.Close(); } catch (Exception ex) { } } private void BindGridForSql() { string connectionString = "Data Source=192.168.0.11;Initial Catalog=30_Nov_13;User ID=sa;Password=super"; string sql = "SELECT * from [@BA_ODPV] "; using (var connection = new SqlConnection(connectionString)) using (var command = new SqlCommand(sql, connection)) using (var adapter = new SqlDataAdapter(command)) { connection.Open(); var dataEntry1 = new DataTable(); adapter.Fill(dataEntry1); dataGridView2.DataSource = dataEntry1; } } private void dataGridView1_DoubleClick(object sender, EventArgs e) { DataGridViewSelectedRowCollection rc = null; rc = dataGridView1.SelectedRows; sno = rc[0].Cells["F1"].Value.ToString(); NOW HERE I WANT TO SEARCH THE SELECTED DATA IN SNO "sno = rc[0].Cells["F1"].Value.ToString();" IN THE BindGridForSql() GRIDVIEW.. THE SNO IS THE BindGridForExcel() GRIDVIEW.. PLZ }
var
This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)