protected void btnUpload_Click(object sender, EventArgs e)
        {
            if (ddlSPList.SelectedValue != "0")
            {
                spListGuid = ddlSPList.SelectedValue.Trim().ToString();
                SPSecurity.RunWithElevatedPrivileges(delegate()
                {
                    try
                    {
                        CreateDirectory();
                        excelPath = HttpContext.Current.Server.MapPath("/_layouts/Temp/" + fuExcelSheet.FileName);
                        if (fuExcelSheet.FileName != string.Empty)
                        {
                            if (excelPath.EndsWith("xls", StringComparison.InvariantCultureIgnoreCase))
                            {
                                excelExten = "xls";
                                xlConn     = new global::System.Data.OleDb.OleDbConnection(Providers.Utilities.ConnUtilities.CreateXlConnectionString(excelPath, excelExten));

                                ddlSheetName.DataSource = DataAccessProvider.GetExcelSheetNames(xlConn);
                                ddlSheetName.DataBind();

                                btnShowData.Visible  = true;
                                ddlSheetName.Visible = true;
                                this.Page.ClientScript.RegisterStartupScript(GetType(), "key", "document.getElementById('light').style.display='block';", true);
                            }
                            else if (excelPath.EndsWith("xlsx", StringComparison.InvariantCultureIgnoreCase))
                            {
                                excelExten = "xlsx";
                                xlConn     = new global::System.Data.OleDb.OleDbConnection(Providers.Utilities.ConnUtilities.CreateXlConnectionString(excelPath, excelExten));

                                ddlSheetName.DataSource = DataAccessProvider.GetExcelSheetNames(xlConn);
                                ddlSheetName.DataBind();

                                this.Page.ClientScript.RegisterStartupScript(GetType(), "key", "document.getElementById('light').style.display='block';", true);
                                litMessage.Text      = string.Empty;
                                btnShowData.Visible  = true;
                                ddlSheetName.Visible = true;
                            }
                            else
                            {
                                litMessage.Text = "Please Upload .xls or .xlsx file";
                            }
                        }
                        else
                        {
                            litMessage.Text = "Please provide a valid file path";
                        }
                    }
                    catch (Exception ex)
                    {
                        litMessage.Text        = "Incorrect Format";
                        rptBindColumns.Visible = false;
                        SPErrorLogs.LogExceptionToSPLog(oWebpartName, "btnUpload_Click", ex);
                    }
                });
            }
        }
Exemple #2
0
 internal static System.Data.DataSet getXldata(System.Data.OleDb.OleDbConnection xlConn, string sheetName, string excelPath, string excelExten)
 {
     System.Data.DataSet ds = new System.Data.DataSet();
     SPSecurity.RunWithElevatedPrivileges(delegate()
     {
         xlConn     = new global::System.Data.OleDb.OleDbConnection(Utilities.ConnUtilities.CreateXlConnectionString(excelPath, excelExten));
         string cmd = string.Format("select * from [{0}]", sheetName);
         System.Data.OleDb.OleDbCommand Comm = new System.Data.OleDb.OleDbCommand(cmd, xlConn);
         Comm.Connection = xlConn;
         System.Data.OleDb.OleDbDataAdapter adapter = new System.Data.OleDb.OleDbDataAdapter();
         xlConn.Open();
         Comm.CommandType      = System.Data.CommandType.Text;
         adapter.SelectCommand = Comm;
         adapter.Fill(ds);
         xlConn.Close();
     });
     return(ds);
 }
 protected void btnShowData_Click(object sender, EventArgs e)
 {
     try
     {
         SPSecurity.RunWithElevatedPrivileges(delegate()
         {
             xlConn = new global::System.Data.OleDb.OleDbConnection(ConnUtilities.CreateXlConnectionString(excelPath, excelExten));
             rptBindColumns.DataSource = DataAccessProvider.getSPListColumns(ddlSPList.SelectedValue.ToString());
             rptBindColumns.DataBind();
             this.Page.ClientScript.RegisterStartupScript(GetType(), "key", "document.getElementById('light').style.display='block';", true);
             btnget.Visible            = true;
             rptBindColumns.Visible    = true;
             litValidationMessage.Text = "";
             litValidationMessage.Text = "";
         });
     }
     catch (Exception ex)
     {
         lblSuccessMessage.Text = "Selected worksheet is not correctly formatted. Please try again.";
         SPErrorLogs.LogExceptionToSPLog(oWebpartName, "btnShowData_Click", ex);
     }
 }
 private void InitConnection() {
     this._connection = new global::System.Data.OleDb.OleDbConnection();
     this._connection.ConnectionString = global::Demo.Properties.Settings.Default.AyumiDB1ConnectionString;
 }
 private void InitConnection() {
     this._connection = new global::System.Data.OleDb.OleDbConnection();
     this._connection.ConnectionString = global::DistribuidoraQuilmes.Properties.Settings.Default.DBConnectionString;
 }
 private void InitConnection() {
     this._connection = new global::System.Data.OleDb.OleDbConnection();
     this._connection.ConnectionString = global::GridEXTutorial23CSharp.Properties.Settings.Default.GridEXTutorialsDataConnectionString;
 }
Exemple #7
0
 private void InitConnection()
 {
     this._connection = new global::System.Data.OleDb.OleDbConnection();
     this._connection.ConnectionString = global::WindowsApplication1.Properties.Settings.Default.nwindConnectionString;
 }
 private void InitConnection() {
     this._connection = new global::System.Data.OleDb.OleDbConnection();
     //this._connection.ConnectionString = global::Sage.Integration.Northwind.Application.Properties.Settings.Default.NorthwindConnectionString;
 }
 private void InitConnection() {
     this._connection = new global::System.Data.OleDb.OleDbConnection();
     this._connection.ConnectionString = global::AmbarTakip.Properties.Settings.Default.AmbarTakipConnectionString;
 }
 private void InitConnection() {
     this._connection = new global::System.Data.OleDb.OleDbConnection();
     this._connection.ConnectionString = global::Payroll_System.Properties.Settings.Default.lamolinventoryConnectionString1;
 }
 private void InitConnection()
 {
     this._connection = new global::System.Data.OleDb.OleDbConnection();
     this._connection.ConnectionString = global::PreviewSortSample.Properties.Settings.Default.nwindConnectionString;
 }
 private void InitConnection() {
     this._connection = new global::System.Data.OleDb.OleDbConnection();
     this._connection.ConnectionString = System.Configuration.ConfigurationManager.ConnectionStrings["NwindConnectionString"].ConnectionString;
 }
 private void InitConnection()
 {
     this._connection = new global::System.Data.OleDb.OleDbConnection();
     this._connection.ConnectionString = global::CustomLabelsWithaLargeAmountOfData.Properties.Settings.Default.nwindConnectionString;
 }
 private void InitConnection() {
     this._connection = new global::System.Data.OleDb.OleDbConnection();
     
 }
Exemple #15
0
 private void InitConnection()
 {
     this._connection = new global::System.Data.OleDb.OleDbConnection();
     this._connection.ConnectionString = global::XtraPivotGrid_ExampleTemplate.Properties.Settings.Default.nwindConnectionString;
 }
Exemple #16
0
 private void InitConnection()
 {
     this._connection = new global::System.Data.OleDb.OleDbConnection();
     this._connection.ConnectionString = global::CustomizeParameterEditorSample.Web.Properties.Settings.Default.nwindConnectionString;
 }
Exemple #17
0
 private void InitConnection() {
     this._connection = new global::System.Data.OleDb.OleDbConnection();
     this._connection.ConnectionString = global::wbswinform.Properties.Settings.Default.wbsConnectionString;
 }
Exemple #18
0
 private void InitConnection()
 {
     this._connection = new global::System.Data.OleDb.OleDbConnection();
     this._connection.ConnectionString = System.Configuration.ConfigurationManager.ConnectionStrings["Tracker08ConnectionString"].ConnectionString;
 }
Exemple #19
0
 private void InitConnection()
 {
     this._connection = new global::System.Data.OleDb.OleDbConnection();
     this._connection.ConnectionString = "Provider=Microsoft.Jet.OLEDB.4.0;Data Source=\"C:\\Program Files\\ComponentOne Studi" +
                                         "o.NET\\common\\C1ListDemo.mdb\"";
 }
 private void InitConnection() {
     this._connection = new global::System.Data.OleDb.OleDbConnection();
     this._connection.ConnectionString = global::JohanBot.Properties.Settings.Default.PelisConnectionString;
 }
Exemple #21
0
 private void InitConnection()
 {
     this._connection = new global::System.Data.OleDb.OleDbConnection();
     this._connection.ConnectionString = "Provider=Microsoft.Jet.OLEDB.4.0;Data Source=\"..\\..\\..\\Data\\C1ListDemo.mdb\"";
 }
 private void InitConnection()
 {
     this._connection = new global::System.Data.OleDb.OleDbConnection();
     this._connection.ConnectionString = global::SchedulerGridSync.Properties.Settings.Default.CarsDBConnectionString;
 }
 private void InitConnection()
 {
     this._connection = new global::System.Data.OleDb.OleDbConnection();
     this._connection.ConnectionString = global::BeforePrintEvent.Properties.Settings.Default.nwindConnectionString;
 }
 private void InitConnection() {
     this._connection = new global::System.Data.OleDb.OleDbConnection();
     this._connection.ConnectionString = global::ParkL.Properties.Settings.Default.ParkLotKainaguaConnectionString;
 }
 private void InitConnection()
 {
     this._connection = new global::System.Data.OleDb.OleDbConnection();
     this._connection.ConnectionString = global::StoreRepInDB.Properties.Settings.Default.ReportsDBConnectionString;
 }
 private void InitConnection() {
     this._connection = new global::System.Data.OleDb.OleDbConnection();
     this._connection.ConnectionString = global::ResultManagement.Properties.Settings.Default.ConnectionString1;
 }
 private void InitConnection() {
     this._connection = new global::System.Data.OleDb.OleDbConnection();
     this._connection.ConnectionString = global::EM.Properties.Settings.Default.em_prog_2002ConnectionString;
 }
 private void InitConnection() {
     this._connection = new global::System.Data.OleDb.OleDbConnection();
     this._connection.ConnectionString = global::IndexDBTables.Properties.Settings.Default.DatabaseConnectionString;
 }