当前位置: 首页>>代码示例>>C#>>正文


C# DB.GetDataTable方法代码示例

本文整理汇总了C#中DB.GetDataTable方法的典型用法代码示例。如果您正苦于以下问题:C# DB.GetDataTable方法的具体用法?C# DB.GetDataTable怎么用?C# DB.GetDataTable使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在DB的用法示例。


在下文中一共展示了DB.GetDataTable方法的4个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C#代码示例。

示例1: GetActiveCustomers_Click

    protected void GetActiveCustomers_Click(object sender, EventArgs e)
    {
        Hashtable State = (Hashtable)HttpRuntime.Cache[Session.SessionID];
        string NoActiveUsersList = Server.MapPath("../../") + @"\App_Data\NoActiveUsersList.txt";
        string[] lines = File.ReadAllLines(NoActiveUsersList);
        Hashtable NoActiveUsersTable = new Hashtable();
        foreach (string line in lines)
        {
            NoActiveUsersTable[line] = true;

        }

        Util util = new Util();
        try
        {
            //Instantiate an instance of license and set the license file through its path

           string  query = "SELECT * FROM customers WHERE last_use_date_time>SUBDATE(NOW(),INTERVAL " + ActiveUsersDaysLoggedIn.Text + " DAY) AND n_logins>=" + ActiveUsersMinNLogins.Text;

            DB db = new DB();
            DataTable myDataTable = db.GetDataTable(query);

            Grid.DataSource = myDataTable;
            Grid.DataBind();
            Grid.MasterTableView.ExportToExcel();

        }
        catch (Exception ex)
        {
            util.ProcessMainExceptions(State, Response, ex);
        }
    }
开发者ID:dcolonvizi,项目名称:ViziAppsPortal,代码行数:32,代码来源:ViewActiveCustomers.aspx.cs

示例2: Init


//.........这里部分代码省略.........
                Splash.Value = 1337;
            }
            ContactCount = Convert.ToInt32(Database.ExecuteScalar("SELECT COUNT(*) FROM Contacts"));
            Out.WriteLine(ContactCount + " contacts found!");

            AnalysisStart = DateTime.Now;
            Out.WriteLine("Analysis started @ " + AnalysisStart.ToLongTimeString());

            Out.WriteLine("Analysing contacts...");
            if (ProgDiag)
            {
                progress.Line1 = "Analysing contacts...";
                progress.Maximum = Convert.ToUInt32(ContactCount);
                progress.Value = 0;
            }
            else
            {
                Splash.Status = "Analysing contacts...";
                Splash.Maximum = ContactCount;
                Splash.Value = 0;
            }

            int limit = 0;
            int step = 1000;
            if (MaxedOutMode == true)
                step = int.MaxValue;

            string columns = Columns(ColumnType.Contact);
            Out.WriteDebug("Using " + columns + " columns.");

            while (limit < ContactCount)
            {
                string query = string.Format("SELECT {0} FROM Contacts LIMIT {1},{2}", columns, limit, limit + step);
                DataTable dt = Database.GetDataTable(query);

                foreach (DataRow row in dt.Rows)
                {
                    foreach (Stat stat in Stats)
                    {
                        stat.RunContactStep(row);
                    }
                }

                limit += step;
                if (ProgDiag) progress.Value += Convert.ToUInt32(step);
                else Splash.AddValue(step);
            }

            Out.WriteLine("Analysing conversations...");
            if (ProgDiag)
            {
                progress.Line1 = "Analysing conversations...";
                progress.Maximum = Convert.ToUInt32(ConvoCount);
                progress.Value = 0;
            }
            else
            {
                Splash.Status = "Analysing conversations...";
                Splash.Maximum = ConvoCount;
                Splash.Value = 0;
            }

            limit = 0;
            step = 1000;
            if (MaxedOutMode == true)
                step = int.MaxValue;
开发者ID:jariz,项目名称:SkypeStats,代码行数:67,代码来源:Core.cs

示例3: ViewAllCustomers_Click

    protected void ViewAllCustomers_Click(object sender, EventArgs e)
    {
        Hashtable State = (Hashtable)HttpRuntime.Cache[Session.SessionID];

        Util util = new Util();
        try
        {
            //Instantiate an instance of license and set the license file through its path

            string query = "SELECT first_name, last_name, company, email, username, phone , registration_date_time FROM customers ";

            DB db = new DB();
            DataTable myDataTable = db.GetDataTable(query);

            Grid.DataSource = myDataTable;
            Grid.DataBind();
            Grid.MasterTableView.ExportToExcel();

        }
        catch (Exception ex)
        {
            util.ProcessMainExceptions(State, Response, ex);
        }
    }
开发者ID:dcolonvizi,项目名称:ViziAppsPortal,代码行数:24,代码来源:Admin.aspx.cs

示例4: LoadData

    private void LoadData()
    {
        try
        {
            Hashtable State = (Hashtable)HttpRuntime.Cache[Session.SessionID];
            DB db = new DB();
            DataTable myDataTable = db.GetDataTable("SELECT application_name, application_type, date_time_modified, production_date_time, status FROM applications WHERE customer_id='" + State["CustomerID"].ToString() +
                "' ORDER BY application_name");
            if (myDataTable.Rows.Count == 0)
            {
                FirstView.Style.Value = "text-align:-moz-center";
                NormalView.Style.Value = "display:none";
                InfoTable.Style.Value = "display:none";
                MySolutions.DataSourceID = String.Empty;
                MySolutions.DataBind();
                return;
            }
            Util util = new Util();
            foreach (DataColumn column in myDataTable.Columns)
            {
                if(column.ColumnName.StartsWith("application"))
                        column.ColumnName = column.ColumnName.Replace("application", "app");
                column.ColumnName = util.CapitalizeWords(column.ColumnName.Replace("_", " "));
            }

            //modify status values
           foreach(DataRow row in myDataTable.Rows)
           {
               row[myDataTable.Columns.Count - 1] = row[myDataTable.Columns.Count - 1].ToString().Replace("/", " / ");
           }

            //add delete column with each row getting an event
            myDataTable.Columns.Add(new DataColumn("x"));

            MySolutions.DataSource = myDataTable;
            MySolutions.DataBind();

            int index = 0;
            foreach (GridDataItem row in MySolutions.Items)
            {
                ImageButton delete_button = new ImageButton();
                delete_button.ImageUrl = "~/images/delete_small.gif";
                delete_button.ID = "delete." + index.ToString();
                delete_button.ToolTip = "Delete this App";
                index++;
                delete_button.Attributes.Add("onclick", "return confirm('Are you sure you want to delete this app?');");
                int delete_cell_index = row.Cells.Count - 1;
                row.Cells[delete_cell_index].Controls.Add(delete_button);
            }
        }
        catch (Exception ex)
        {
            throw new Exception(ex.Message + ": " + ex.StackTrace);
        }
    }
开发者ID:dcolonvizi,项目名称:ViziAppsPortal,代码行数:55,代码来源:TabMySolutions.aspx.cs


注:本文中的DB.GetDataTable方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。