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


C# DBConnector.ExecuteReader方法代码示例

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


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

示例1: GetPaymentsAsync

        public Task<IEnumerable<PaymentInfo>> GetPaymentsAsync(DateTime start, CancellationToken cancellationToken)
        {
            DB.RegisterFactory("MySql", MySql.Data.MySqlClient.MySqlClientFactory.Instance);
            DB.RegisterFactory("MySql.Data.MySqlClient", MySql.Data.MySqlClient.MySqlClientFactory.Instance);

            var db = new DBConnector(Config.GetElement("Databases", "WordPress"));

            using (var reader = db.ExecuteReader(@"
            SELECT p.id, s.name,
            us.billingFirstName, us.billingLastName, us.billingCompany,
            us.billingAddress, us.billingCity, us.billingState, us.billingZip, us.billingCountry, us.billingPhone,
            us.emailAddress,
            us.lastFourDigitsOfCreditCard, p.xAmount, p.paymentDate,
            us.subscriptionNotes, us.userIP,
            CONVERT(p.fullAuthorizeNetResponse USING utf8) AS response
            FROM wp_authnet_user_subscription us
            JOIN wp_authnet_payment p ON us.ID = p.user_subscription_id
            LEFT JOIN wp_authnet_subscription s ON s.ID = p.xSubscriptionId
            WHERE p.paymentDate > ?start", new { start })) {
                return Task.FromResult<IEnumerable<PaymentInfo>>(reader.Cast<IDataRecord>()
                             .Select(dr => new PaymentInfo {
                                 Id = dr.GetString(dr.GetOrdinal("id")),
                                 Email = dr.GetString(dr.GetOrdinal("emailAddress")),
                                 FinalFour = dr.GetString(dr.GetOrdinal("lastFourDigitsOfCreditCard")),
                                 CardIssuer = dr.GetString(dr.GetOrdinal("response")).Split('|')[51],
                                 Date = dr.GetDateTime(dr.GetOrdinal("paymentDate")),
                                 Amount = dr.GetDecimal(dr.GetOrdinal("xAmount")),
                                 Comments = dr.GetString(dr.GetOrdinal("subscriptionNotes"))
                                          + "\nIP Address: " + dr.GetString(dr.GetOrdinal("userIP"))
                             })
                             .ToList());
            }
        }
开发者ID:ShomreiTorah,项目名称:Billing,代码行数:33,代码来源:WpAuthNetSource.cs

示例2: ShowComments

 //显示注释
 private void ShowComments()
 {
     LabelComments.Text = "";
     LabelComments.Text += "<table>";
     String strSql = string.Format("select Users.Name, Comments.CommentTime, Comments.Comment from Comments, Users " +
         "where FileMd5 = '{0}' and Comments.CommenterId = Users.ID", StrMd5);
     DBConnector db = new DBConnector();
     using (SqlDataReader dr = db.ExecuteReader(strSql))
     {
         while (dr.Read())
         {
             LabelComments.Text += "<tr><td align=\"left\">";
             LabelComments.Text += dr.GetString(0) + "\t" + dr.GetDateTime(1).ToString();
             LabelComments.Text += "</td></tr><tr align=\"left\" valign=\"top\"><td>";
             LabelComments.Text += dr.GetString(2);
             LabelComments.Text += "</td></tr>";
         }
         dr.Close();
     }
     LabelComments.Text += "</table>";
 }
开发者ID:dalinhuang,项目名称:zhaoxiang,代码行数:22,代码来源:ViewFile.aspx.cs

示例3: Page_Load

    protected void Page_Load(object sender, EventArgs e)
    {
        if (Helper.UserId == 0)
        {
            ButtonDownload.Enabled = false;
        }
        if (!IsPostBack)
        {
            //获取下载地址
            if (Request.QueryString["MD5"] != null)
            {
                StrMd5 = Request.QueryString["MD5"];

                String strSql = "Select UploaderId, FilePath, FileName, Point From Files Where MD5='"
                    + Request.QueryString["MD5"] + "'";
                DBConnector db = new DBConnector();
                using (SqlDataReader dr = db.ExecuteReader(strSql))
                {
                    while (dr.Read())
                    {
                        StrFilePathName = dr.GetString(1) + dr.GetString(2);
                        IUploaderId = dr.GetInt32(0);
                        IFilePoint = dr.GetInt32(3);
                    }
                    dr.Close();
                }
                //如果不是管理员或者上传者,应取消编辑和删除按钮,取消下载记录
                if (!(Helper.IsAdmin || IUploaderId == Helper.UserId))
                {
                    ButtonEdit.Visible = false;
                    ButtonDelete.Visible = false;
                    GridViewDownload.Visible = false;
                    LabelDownloads.Visible = false;
                }
                else
                {
                    ButtonEdit.Visible = true;
                    ButtonDelete.Visible = true;
                    GridViewDownload.Visible = true;
                    LabelDownloads.Visible = true;
                }

                //增加下载次数
                strSql = "Update Files set ViewCount = (Select ViewCount From Files Where MD5='" + StrMd5 +
                    "') + 1 Where MD5='" + StrMd5 + "'";

                db.ExecuteNonQuery(strSql);

                ShowComments();
            }
            else
            {
                Response.Redirect("Default.aspx");
            }

        }
    }
开发者ID:dalinhuang,项目名称:zhaoxiang,代码行数:57,代码来源:ViewFile.aspx.cs

示例4: ReadSchemas

        public static IEnumerable<SchemaModel> ReadSchemas(DataContextModel owner, DBConnector database)
        {
            if (database == null) throw new ArgumentNullException("database");

            List<SchemaModel> tables = new List<SchemaModel>();
            List<Action> postColumnActions = new List<Action>();

            Func<string, string, SchemaModel> Table = (schema, name) =>	//First look for a new table from SQL Server, then for an existing one.
                String.IsNullOrEmpty(name) ? null : tables.SingleOrDefault(t => t.SqlSchemaName == schema && t.SqlName == name)
                                                 ?? owner.Schemas.SingleOrDefault(t => t.SqlSchemaName == schema && t.SqlName == name);

            using (var connection = database.OpenConnection()) {
                #region Read Tables
                using (var reader = database.ExecuteReader(TablesSql)) {
                    while (reader.Read()) {
                        var table = new SchemaModel(owner) {
                            Name = (string)reader["TableName"],
                            SqlName = (string)reader["TableName"],
                            SqlSchemaName = reader["SchemaName"] as string
                        };

                        if (Table(table.SqlSchemaName, table.SqlName) != null) continue;	//TODO: Import column

                        string keyName = reader["PrimaryKeyName"] as string;
                        if (!String.IsNullOrEmpty(keyName)) {
                            postColumnActions.Add(
                                () => table.PrimaryKey = table.Columns.Single(c => c.SqlName == keyName)
                            );
                        }

                        tables.Add(table);
                    }
                }
                #endregion

                using (var reader = database.ExecuteReader(ColumnsSql)) {
                    while (reader.Read()) {
                        var table = Table((string)reader["SchemaName"], (string)reader["TableName"]);
                        if (table == null) continue;	//Skip tables without RowVersion columns

                        var name = (string)reader["ColumnName"];
                        if (table.Columns.Any(c => c.SqlName == name))
                            continue;	//Don't add duplicate columns to existing tables.

                        table.Columns.Add(new ColumnModel(table) {
                            Name = name,
                            SqlName = name,
                            DataType = SqlTypes[(string)reader["DataType"]],

                            AllowNulls = 1 == (int)reader["AllowNulls"],
                            IsUnique = 1 == (int)reader["IsUnique"],

                            ForeignSchema = Table(reader["ForeignSchema"] as string, reader["ForeignTable"] as string)
                        });
                    }
                }
            }

            postColumnActions.ForEach(a => a());

            return tables;
        }
开发者ID:ShomreiTorah,项目名称:Utilities,代码行数:62,代码来源:SqlReader.cs


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