setting datasource of Grid View Problem
-
i m using following code to set Datasource of gridview but its not working plz help
string path = Directory.GetCurrentDirectory();
string conn = "Provider=Microsoft.Jet.OLEDB.4.0;Data Source=" + path + "\\cricketdb.mdb";OleDbConnection con = new OleDbConnection(conn); OleDbCommand cmd = con.CreateCommand(); cmd.CommandType = CommandType.Text; cmd.CommandText = "SELECT \* FROM countryinfo"; OleDbDataAdapter da = new OleDbDataAdapter(cmd); DataSet ds = new DataSet("countryinfo"); OleDbCommandBuilder oldbcbr = new OleDbCommandBuilder(da); da.Fill(ds, "countryinfo"); dataGridView1.DataSource = ds; comboBox2.DataSource = ds.Tables\["Country\_Name"\]; listBox1.DataSource = ds.DefaultViewManager; listBox1.DisplayMember = "Country\_Name"; dataGridView1.DataSource = ds; DataTable dt = new DataTable(); da.Fill(dt); dataGridView1.DataSource = dt; comboBox2.DataSource = dt;
Its also not setting datasource of anycontrol like combo or list plz help
-
i m using following code to set Datasource of gridview but its not working plz help
string path = Directory.GetCurrentDirectory();
string conn = "Provider=Microsoft.Jet.OLEDB.4.0;Data Source=" + path + "\\cricketdb.mdb";OleDbConnection con = new OleDbConnection(conn); OleDbCommand cmd = con.CreateCommand(); cmd.CommandType = CommandType.Text; cmd.CommandText = "SELECT \* FROM countryinfo"; OleDbDataAdapter da = new OleDbDataAdapter(cmd); DataSet ds = new DataSet("countryinfo"); OleDbCommandBuilder oldbcbr = new OleDbCommandBuilder(da); da.Fill(ds, "countryinfo"); dataGridView1.DataSource = ds; comboBox2.DataSource = ds.Tables\["Country\_Name"\]; listBox1.DataSource = ds.DefaultViewManager; listBox1.DisplayMember = "Country\_Name"; dataGridView1.DataSource = ds; DataTable dt = new DataTable(); da.Fill(dt); dataGridView1.DataSource = dt; comboBox2.DataSource = dt;
Its also not setting datasource of anycontrol like combo or list plz help
-
Is it shows any error ?
Life's Like a mirror. Smile at it & it smiles back at you.- P Pilgrim So Smile Please
No it does not compiles any error but display nothing in gridview
-
i m using following code to set Datasource of gridview but its not working plz help
string path = Directory.GetCurrentDirectory();
string conn = "Provider=Microsoft.Jet.OLEDB.4.0;Data Source=" + path + "\\cricketdb.mdb";OleDbConnection con = new OleDbConnection(conn); OleDbCommand cmd = con.CreateCommand(); cmd.CommandType = CommandType.Text; cmd.CommandText = "SELECT \* FROM countryinfo"; OleDbDataAdapter da = new OleDbDataAdapter(cmd); DataSet ds = new DataSet("countryinfo"); OleDbCommandBuilder oldbcbr = new OleDbCommandBuilder(da); da.Fill(ds, "countryinfo"); dataGridView1.DataSource = ds; comboBox2.DataSource = ds.Tables\["Country\_Name"\]; listBox1.DataSource = ds.DefaultViewManager; listBox1.DisplayMember = "Country\_Name"; dataGridView1.DataSource = ds; DataTable dt = new DataTable(); da.Fill(dt); dataGridView1.DataSource = dt; comboBox2.DataSource = dt;
Its also not setting datasource of anycontrol like combo or list plz help