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


C# Data.DataColumnCollection类代码示例

本文整理汇总了C#中System.Data.DataColumnCollection的典型用法代码示例。如果您正苦于以下问题:C# DataColumnCollection类的具体用法?C# DataColumnCollection怎么用?C# DataColumnCollection使用的例子?那么恭喜您, 这里精选的类代码示例或许可以为您提供帮助。


DataColumnCollection类属于System.Data命名空间,在下文中一共展示了DataColumnCollection类的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C#代码示例。

示例1: EntityCreatingArgs

 /// <summary>
 /// 初始化新的实体创建参数
 /// </summary>
 /// <param name="index">索引</param>
 /// <param name="row">当前数据行</param>
 /// <param name="columns">数据列集合</param>
 /// <param name="extraArg">额外参数</param>
 internal EntityCreatingArgs(Int32 index, DataRow row, DataColumnCollection columns, Object extraArg)
 {
     this._index = index;
     this._row = row;
     this._columns = columns;
     this._extraArg = extraArg;
 }
开发者ID:svcdn,项目名称:DotMaysWind.Data,代码行数:14,代码来源:EntityCreatingArgs.cs

示例2: DataRowToJson

 /// <summary>
 /// 单行数据转为Json
 /// </summary>
 /// <param name="row"></param>
 /// <param name="columns"></param>
 /// <returns></returns>
 /// <remarks></remarks>
 public static string DataRowToJson(DataRow row, DataColumnCollection columns)
 {
     StringBuilder json = new StringBuilder("{");
     for (int i = 0; i <= columns.Count - 1; i++)
     {
         DataColumn c = columns[i];
         if (c.DataType.Name == "String")
         {
             json.AppendFormat("\"{0}\":\"{1}\"", c.ColumnName, row[c.ColumnName].ToString().Replace(@"\", @"\\").Replace("'", "\'").Replace("\"", "\\\""));
         }
         else if (c.DataType.Name == "DateTime")
         {
             json.AppendFormat("\"{0}\":\"{1}\"", c.ColumnName, row[c.ColumnName].ToString());
         }
         else if (c.DataType.Name == "Boolean")
         {
             json.AppendFormat("\"{0}\":\"{1}\"", c.ColumnName, (Convert.ToBoolean(row[c.ColumnName]) ? "true" : "false"));
         }
         else if (c.DataType.Name == "Byte[]")
         {
             json.AppendFormat("\"{0}\":\"{1}\"", c.ColumnName, Encoding.UTF8.GetString((byte[])row[c.ColumnName]));
         }
         else
         {
             json.AppendFormat("\"{0}\":{1}", c.ColumnName, (row[c.ColumnName].Equals(DBNull.Value) ? "\"\"" : row[c.ColumnName].ToString()));
         }
         json.Append((i < columns.Count - 1 ? "," : "}"));
     }
     return json.ToString();
 }
开发者ID:sundawn,项目名称:JapaneseLearn,代码行数:37,代码来源:JSON.cs

示例3: getJsonListByRow

        /// <summary>
        /// Gets the json list by row.
        /// </summary>
        /// <param name="row">The row.</param>
        /// <returns></returns>
        /// <Remarks>
        /// Created Time: 08-10-14 12:38
        /// Created By: jack_que
        /// Last Modified Time:  
        /// Last Modified By: 
        /// </Remarks>
        public static Dictionary<string, string> getJsonListByRow(DataRow row, DataColumnCollection columns, string format)
        {
            Dictionary<string, string> dic = new Dictionary<string, string>();

            foreach (DataColumn column in columns)
            {
                string columnName = column.ColumnName.ToLower();
                object value = row[column];
                string valueString = string.Empty;

                if (column.DataType.FullName.Equals("System.DateTime") && !value.ToString().Equals(string.Empty))
                {
                    valueString = ((DateTime)value).ToString(format);
                }
                else if (column.DataType.FullName.Equals("System.Decimal") && !value.ToString().Equals(string.Empty))
                {
                    valueString = GetDecimalString(value, columnName);
                }
                else
                {
                    valueString = value.ToString();
                }
                dic.Add(columnName, valueString);
            }

            return dic;
        }
开发者ID:jimidzj,项目名称:Inspect,代码行数:38,代码来源:JsonHelper.cs

示例4: EnumerablePermuter_Freq

 public EnumerablePermuter_Freq(DataColumnCollection pContext, RunModeEnum pRunMode, ref string[] pStratavarList, ref List<string> pSelectClauses)
 {
     this.RunMode = pRunMode;
     this.StrataVarList = pStratavarList;
     this.SelectClaues = pSelectClauses;
     this.Columns = pContext;
 }
开发者ID:NALSS,项目名称:epiinfo-82474,代码行数:7,代码来源:Frequency.cs

示例5: ApplyFormatRules

        private void ApplyFormatRules(DataColumnCollection DCols, DataRow dRow, ListViewItem lvItem)
        {
            if (this.iSearchConfig.ResultFormatRules.Count < 1)
                return;

                object[] colvalues = dRow.ItemArray;

                for (int i = 0; i < DCols.Count; i++)
                {

                   foreach (SearchResultFormatRule srFormatRule in this.iSearchConfig.ResultFormatRules)
                   {

                       if ((DCols[i].ColumnName == srFormatRule.MatchField) && (colvalues[i].ToString() == srFormatRule.MatchValue))
                       {
                           /* rules match ! */
                           if (srFormatRule.Type == SearchResultFormatRule.RuleType.Colour)
                           {
                               /* Colour means to change the colour of text only */
                               lvItem.ForeColor = Color.FromName(srFormatRule.Colour); //( srFormatRule.Colour;
                           }

                       }
                   }
                }
        }
开发者ID:trinitycore-dbgui,项目名称:trinitycore-dbgui-vispa,代码行数:26,代码来源:frmSearch.cs

示例6: insertTbl

        /// <summary>批量导入DataTable  
        /// 批量导入DataTable  
        /// </summary>  
        /// <param name="dt">DataTable数据表</param>  
        /// <param name="tblName">表名</param>  
        /// <param name="dtColumn">数据列集合</param>  
        /// <return>Boolean值:true成功,false失败</return>  
        public static Boolean insertTbl(DataTable dt, String tblName, DataColumnCollection dtColumn)
        {
            try
            {
                using (SqlBulkCopy sqlBC = new SqlBulkCopy(connString))
                {
                    //一次批量的插入的数据量
                    sqlBC.BatchSize = 1000;
                    //超时之前操作完成所允许的秒数,如果超时则事务不会提交 ,数据将回滚,所有已复制的行都会从目标表中移除
                    sqlBC.BulkCopyTimeout = 60;

                    //设置要批量写入的表
                    sqlBC.DestinationTableName = tblName;

                    //自定义的datatable和数据库的字段进行对应
                    //sqlBC.ColumnMappings.Add("id", "tel");
                    //sqlBC.ColumnMappings.Add("name", "neirong");
                    for (int i = 0; i < dtColumn.Count; i++)
                    {
                        sqlBC.ColumnMappings.Add(dtColumn[i].ColumnName.ToString(), dtColumn[i].ColumnName.ToString());
                    }
                    //批量写入
                   VipSoft.Common.NPOI2.ExcelUtils.printDT(dt);
                    sqlBC.WriteToServer(dt);
                }
            }
            catch(Exception e)
            {
                Console.Write(e.Message);
                return false;
            }
            return true;
        }
开发者ID:freedomwork,项目名称:playground,代码行数:40,代码来源:SqlHelper.cs

示例7: DataTable

		public DataTable()
		{
			Columns = new DataColumnCollection(this);
			Rows = new DataRowCollection(this);
			Locale = CultureInfo.CurrentCulture;
			DefaultView = new DataView(this);
		}
开发者ID:hungdluit,项目名称:aforge,代码行数:7,代码来源:DataTable.cs

示例8: CourseRubricObject

 public CourseRubricObject(DataColumnCollection columns, DataRow row)
 {
     this.id = columns.Contains("id") ? Convert.ToInt32(row["id"]) : -1;
     this.courseId = columns.Contains("course_id") ? Convert.ToInt32(row["course_id"]) : -1;
     this.courseName = columns.Contains("course_name") ? Convert.ToString(row["course_name"]) : "-";
     this.rubricName = columns.Contains("rubric_name") ? Convert.ToString(row["rubric_name"]) : "-";
 }
开发者ID:idurlen92,项目名称:E_Grader,代码行数:7,代码来源:CourseRubricObject.cs

示例9: UpdateUserProfileByAccount

        public static UserProfileUpdateStatus UpdateUserProfileByAccount(UserProfileManager upm, string account, DataRow userInfo, DataColumnCollection columns)
        {
            upm.AssertNotNull("upm");
            userInfo.AssertNotNull("userInfo");
            columns.AssertNotNull("columns");

            bool exists = upm.UserExists(account);

            UserProfile profile = exists ? upm.GetUserProfile(account) : upm.CreateUserProfile(account);

            foreach (string colName in from DataColumn column in columns select column.ColumnName)
            {
                bool editable = profile[colName].Property.IsAdminEditable;

                if (editable)
                {
                    try
                    {
                        profile[colName].Value = userInfo[colName];
                    }
                    catch
                    {
                    }
                }

            }

            profile.Commit();

            return exists ? UserProfileUpdateStatus.Updated : UserProfileUpdateStatus.NewlyAdded;
        }
开发者ID:zhoutaomtv,项目名称:ca,代码行数:31,代码来源:SPHelper.cs

示例10: DatabaseTableInfo

 /// <summary>
 /// Constructor.
 /// </summary>
 /// <param name="row">The row definition.</param>
 /// <param name="name">The table name.</param>
 /// <param name="rowCount">The number of rows in the table.</param>
 /// <param name="columns">Information on the column tables.</param>
 public DatabaseTableInfo(DataRow row, string name, int rowCount,
     DataColumnCollection columns)
 {
     Name = name;
     Data = row;
     RowCount = rowCount;
     Columns = columns;
 }
开发者ID:Huddle,项目名称:Puddle,代码行数:15,代码来源:DatabaseTableInfo.cs

示例11: RowEqual

 private bool RowEqual(DataRow rowA, DataRow rowB, DataColumnCollection columns)
 {
     bool result = true;
     for (int i = 0; i < columns.Count; i++)
     {
         result &= ColumnEqual(rowA[columns[i].ColumnName], rowB[columns[i].ColumnName]);
     }
     return result;
 }
开发者ID:Johnnyfly,项目名称:source20131023,代码行数:9,代码来源:ZDataset.cs

示例12: Init

 public void Init(DataColumnCollection columns)
 {
     Columns = columns;
     this.listBoxControl1.Items.Clear();
     foreach (DataColumn column in this.Columns)
     {
         this.listBoxControl1.Items.Add(column.ColumnName);
     }
 }
开发者ID:supergfox,项目名称:SPC,代码行数:9,代码来源:ConfigControl.cs

示例13: DynamicDataSet

 public DynamicDataSet(Func<DataRow> dataRow, DataColumnCollection dataColumns)
 {
     this._dataRow = dataRow;
     _dataColumns = new List<DataColumn>();
     foreach (var col in this._dataColumns)
     {
         _dataColumns.Add(col);
     }
 }
开发者ID:mykge,项目名称:sealong.o2o,代码行数:9,代码来源:DynamicDataSet.cs

示例14: AssumeColumn

 //
 private string AssumeColumn(DataColumnCollection col)
 {
     int ColumnsCount = col.Count;
     List<string> header = new List<string>();
     for (int i = 0; i < ColumnsCount; i++){
       header.Add(col[i].Caption);
     }
     return AssumeLine(header.ToArray());
 }
开发者ID:norick1701,项目名称:ExportCSV,代码行数:10,代码来源:OutputCSV.cs

示例15: InsertIntoTempTable

 public void InsertIntoTempTable(int iBatchID, DataColumnCollection columns, DataRow dr)
 {
     List<SqlParameter> parameters = new List<SqlParameter>();
     parameters.Add(new SqlParameter("@BatchID", iBatchID));
     foreach (DataColumn dc in columns)
     {
         parameters.Add(new SqlParameter("@" + dc.ColumnName, dr[dc.ColumnName].ToString()));
     }
     ExecuteNonQuery("spN_ins_RegistrationUploads", parameters.ToArray(), CommandType.StoredProcedure);
 }
开发者ID:yousuf84,项目名称:Project1,代码行数:10,代码来源:RegistrationUploadDataAccess.cs


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