當前位置: 首頁>>代碼示例>>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;未經允許,請勿轉載。