Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- public void BindData(string mySQL)
- {
- OracleConnection myConnection;
- OracleDataAdapter TempDataAdapter;
- DataSet MainDataSet = new DataSet();
- DataTable MainDataTable = new DataTable();
- DataSet TempDataSet;
- DataTable TempDataTable;
- string connectionString = "";
- Label1.Visible = false;
- Label1.Text = "";
- foreach (ListItem li in CheckBoxList1.Items)
- {
- if (li.Selected)
- {
- connectionString = "Data Source=" + li.Text + "";
- connectionString += ";Persist Security Info=True;User ID=user;Password=pass;Unicode=True";
- myConnection = new OracleConnection(connectionString);
- try
- {
- TempDataAdapter = new OracleDataAdapter(mySQL, myConnection);
- TempDataSet = new DataSet();
- TempDataTable = new DataTable();
- TempDataAdapter.Fill(TempDataSet);
- TempDataTable = TempDataSet.Tables[0].Copy();
- /* If the main dataset is empty, create a table by cloning from temp dataset, otherwise
- copy all rows to existing table.*/
- if (MainDataSet.Tables.Count == 0)
- {
- MainDataSet.Tables.Add(TempDataTable);
- MainDataTable = MainDataSet.Tables[0];
- }
- else
- {
- foreach (DataRow dr in TempDataTable.Rows)
- {
- MainDataTable.ImportRow(dr);
- }
- }
- }
- catch (OracleException e)
- {
- Label1.Visible = true;
- Label1.Text = Label1.Text + e.Message + " on " + li.Text + "<br>";
- }
- finally
- {
- if (myConnection != null)
- {
- myConnection.Close();
- myConnection = null;
- }
- TempDataSet = null;
- TempDataAdapter = null;
- TempDataTable = null;
- }
- }
- }
- GridView1.DataSourceID = String.Empty;
- if (MainDataSet.Tables.Count != 0)
- {
- GridView1.DataSource = MainDataSet;
- if (GridView1.DataSource != null)
- {
- GridView1.DataBind();
- }
- }
- }
- protected void Button1_Click(object sender, EventArgs e)
- {
- BindData(TextBox1.Text);
- }
- public void BindData(string mySQL)
- {
- OracleConnection myConnection;
- // Empty connection string for now
- OracleDataAdapter MainDataAdapter = new OracleDataAdapter(mySQL, "");
- DataTable MainDataTable = new DataTable();
- string connectionString = "";
- Label1.Visible = false;
- Label1.Text = "";
- foreach (ListItem li in CheckBoxList1.Items)
- {
- if (li.Selected)
- {
- connectionString = "Data Source=" + li.Text + "";
- connectionString += ";Persist Security Info=True;User ID=user;Password=pass;Unicode=True";
- MainDataAdapter.SelectCommand.Connection.ConnectionString = connectionString
- try
- {
- MainDataAdapter.Fill(MainDataTable);
- }
- catch (OracleException e)
- {
- Label1.Visible = true;
- Label1.Text = Label1.Text + e.Message + " on " + li.Text + "<br>";
- }
- }
- }
- GridView1.DataSourceID = String.Empty;
- GridView1.DataSource = MainDataTable;
- GridView1.DataBind();
- }
Add Comment
Please, Sign In to add comment