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


C# DataTable.LoadDataRow方法代码示例

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


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

示例1: aboutList

        public static string aboutList()
        {
            StringBuilder strTxt = new StringBuilder();
            DataTable tbl = new DataTable();
            tbl.Columns.Add("Title", typeof(string));
            tbl.Columns.Add("Url", typeof(string));
            object[] aValues = { "公司简介", "About.aspx" };
            tbl.LoadDataRow(aValues, true);
            object[] aValues1 = { "招聘信息", "Jobs.aspx" };
            tbl.LoadDataRow(aValues1, true);
            object[] aValues2 = { "站点地图", "SiteMap.aspx" };
            tbl.LoadDataRow(aValues2, true);
            object[] aValues3 = { "联系我们", "ContactInfo.aspx" };
            tbl.LoadDataRow(aValues3, true);

            if (tbl.Rows.Count > 0)
            {
                strTxt.Append("<dl>");
                for (int j = 0; j < tbl.Rows.Count; j++)
                {
                    DataRow dr2 = tbl.Rows[j];
                    strTxt.Append("<dd style=\"background-color: rgb(239,239,239); height: 26px;\">");
                    strTxt.Append("<a class=\"channelClass01\" href=\""+ dr2["Url"].ToString() +"\" style=\"position: relative;top: 5px; left: 15px;\">" + dr2["Title"].ToString() + "</a>");
                    strTxt.Append("</dd>");
                }
                strTxt.Append("</dl>");
            }
            else
                strTxt.Append("暂无栏目!");
            return strTxt.ToString();
        }
开发者ID:BGCX261,项目名称:zhongzhiweb-svn-to-git,代码行数:31,代码来源:Channel.cs

示例2: CommasInDataDataTable

 public static DataTable CommasInDataDataTable()
 {
     DataTable dataTable = new DataTable();
     dataTable.Columns.Add("First");
     dataTable.Columns.Add("Second");
     dataTable.Columns.Add("Third");
     dataTable.LoadDataRow(new object[] { "a,a", "b,b", "c,c" }, false);
     dataTable.LoadDataRow(new object[] { "a1,a1", "b1,b1", "c1,c1" }, false);
     return dataTable;
 }
开发者ID:kevinbosman,项目名称:habanero,代码行数:10,代码来源:CsvTestsSamples.cs

示例3: Main

        static void Main(string[] args)
        {
            DataTable cave = new DataTable("Cave"); // création de la table "Cave" (vide pour l'instant)

            DataColumn id = new DataColumn("ID");
            id.DataType = typeof(int);
            id.AutoIncrement = true; // active l'autoincrémentation de la colonne
            id.AutoIncrementSeed = 1; // valeur de départ pour l'autoincrémentation
            id.AutoIncrementStep = 1; // pas pour l'autoincrémentation
            cave.Columns.Add(id);
            cave.PrimaryKey = new DataColumn[] { id }; // désignation de la colonne "ID" comme clé primaire de la table

            DataColumn vin = new DataColumn("Vin"); // création d'une colonne "Vin"
            vin.DataType = typeof(string); // le type de données est string par défaut, cette ligne est donc optionelle
            vin.Unique = true; // détermine si les valeurs de la colonnes doivent être uniques (false par défaut)
            vin.AllowDBNull = false; // détermine si la colonne accepte les valeurs NULL (true par défaut)
            vin.Caption = "Vin"; // nom que portera la colonne dans la représentation graphique (par défaut, c'est le nom de la colonne spécifié lors de la déclaration)
            cave.Columns.Add(vin); // la colonne "Vin" est ajoutée à la table "Cave"

            DataColumn annee = new DataColumn("Annee", typeof(int)); // on peut utiliser le constructeur à 2 paramètres pour déclarer une nouvelle colonne tout en spécifiant son type
            annee.AllowDBNull = false;
            annee.Caption = "Année";
            cave.Columns.Add(annee);

            DataColumn marque = new DataColumn("Marque");
            marque.MaxLength = 35;  // détermine la taille maximale dans le cas d'un string (-1 par défaut, càd illimité)
            marque.AllowDBNull = false;
            cave.Columns.Add(marque);

            // la colonne suivante est une colonne dérivée des colonnes "Marque" et "Année"
            DataColumn marqueEtAnnee = new DataColumn("MarqueEtAnnee");
            marqueEtAnnee.MaxLength = 40;
            marqueEtAnnee.Expression = "Annee + ' ' + Marque"; // la propriété "Expression" permet de concaténer les valeurs de plusieurs colonnes
            marqueEtAnnee.Caption = "Marque et Année";
            cave.Columns.Add(marqueEtAnnee);

            // remplissage de la table
            DataRow newCave = cave.NewRow(); // création de la ligne à insérer
            newCave["Vin"] = "Beaujolais";
            newCave["Marque"] = "Grand Cru";
            newCave["Annee"] = 1982;
            cave.Rows.Add(newCave); // ajout de la ligne à la table "Cave"

            cave.LoadDataRow(new object[] { null, "Bourgogne", 2012, "Prix 2012" }, true); // une autre méthode d'ajout de lignes
            cave.LoadDataRow(new object[] { null, "Saint-Emilion", 1983, "Cuvée Prestige" }, true);
            cave.LoadDataRow(new object[] { null, "Pommard", 1959, "Clos Blanc" }, true);

            printTable(cave);
        }
开发者ID:ZipionLive,项目名称:ADO-Disconnected,代码行数:49,代码来源:Program.cs

示例4: GetRecord

        public DataTable GetRecord()
        {
            FinesStyleInfoRequery finesStyleInfo = new FinesStyleInfoRequery();
            IList iList=finesStyleInfo.FinesInfoRequery(null);
            if (iList == null)
                return null;

            DataTable result = new DataTable();
            if (iList.Count > 0)
            {
                PropertyInfo[] propertys = iList[0].GetType().GetProperties();
                foreach (PropertyInfo pi in propertys)
                {
                    result.Columns.Add(pi.Name, pi.PropertyType);
                }

                for (int i = 0; i < iList.Count; i++)
                {
                    ArrayList tempList = new ArrayList();
                    foreach (PropertyInfo pi in propertys)
                    {
                        object obj = pi.GetValue(iList[i], null);
                        tempList.Add(obj);
                    }
                    object[] array = tempList.ToArray();
                    result.LoadDataRow(array, true);
                }
            }
            return result;
        }
开发者ID:kooyou,项目名称:TrafficFinesSystem,代码行数:30,代码来源:FinesStyleRequery.cs

示例5: getTable

        private static DataTable getTable(string xmlTable_)
    {
      var doc = new System.Xml.XmlDocument();
      doc.LoadXml(xmlTable_);

      DataTable dt = new DataTable();

      foreach (XmlNode rowNode in doc.DocumentElement.SelectNodes("./Table/Rows/Row"))
      {
        if (dt.Columns.Count == 0)
        {
          foreach (XmlNode node in rowNode.SelectNodes("./string"))
            dt.Columns.Add(node.InnerText);
        }
        else
        {
          string[] vals = new string[dt.Columns.Count];
          XmlNodeList list = rowNode.SelectNodes("./string");

          for (int i = 0; i < list.Count; ++i)
            vals[i] = list[i].InnerText;
          dt.LoadDataRow(vals, true);
        }
      }

      return dt;

    }
开发者ID:heimanhon,项目名称:researchwork,代码行数:28,代码来源:Retriever.cs

示例6: GenerateLargeInputTable

		private static DataTable GenerateLargeInputTable()
		{
			var sourceTable = new DataTable();
			sourceTable.Columns.Add("BeginTime", typeof(DateTime));
			sourceTable.Columns.Add("EndTime", typeof(DateTime));
			sourceTable.Columns.Add("TravelTypeId", typeof(short));

			for (var date = new DateTime(1000, 1, 1); date.Year <= 3000; date = date.AddDays(3))
			{
				sourceTable.LoadDataRow(new object[] { date.AddHours(8.0), date.AddHours(10.0), (short)0 }, LoadOption.OverwriteChanges);
				sourceTable.LoadDataRow(new object[] { date.AddHours(17.0), date.AddHours(19.0), (short)1 }, LoadOption.OverwriteChanges);
				sourceTable.LoadDataRow(new object[] { date.AddHours((24.0 * 2) + 17.0), date.AddHours((24.0 * 2) + 19.0), (short)2 }, LoadOption.OverwriteChanges);
			}

			return sourceTable;
		}
开发者ID:mkandroid15,项目名称:Samples,代码行数:16,代码来源:Program.cs

示例7: ConvertDataReaderToDataTable

        public static DataTable ConvertDataReaderToDataTable(DbDataReader reader)
        {
            try
            {
                DataTable table = new DataTable();
                int fieldCount = reader.FieldCount;
                for (int fieldIndex = 0; fieldIndex < fieldCount; ++fieldIndex)
                {
                    table.Columns.Add(reader.GetName(fieldIndex), reader.GetFieldType(fieldIndex));
                }

                table.BeginLoadData();

                object[] rowValues = new object[fieldCount];
                while (reader.Read())
                {
                    reader.GetValues(rowValues);
                    table.LoadDataRow(rowValues, true);
                }
                reader.Close();
                table.EndLoadData();

                return table;

            }
            catch (Exception ex)
            {
                throw new Exception("DataReader转换为DataTable时出错!", ex);
            }
        }
开发者ID:piaolingzxh,项目名称:Justin,代码行数:30,代码来源:DBHelper.cs

示例8: ConvertToDataTable

        private static DataTable ConvertToDataTable(object[] excelObjctData, string primaryKeyValue, string colsKeyValue)
        {
            Hashtable colsHash = ParseCols(colsKeyValue);

            DataTable dt = new DataTable();

            if (excelObjctData.Length > 0)
            {
                for (int i = 0; i < ((object[])excelObjctData[0]).Length; i++)
                {
                    dt.Columns.Add(ToTagName(i));
                }

                foreach (object[] objs in excelObjctData)
                {
                    if (objs[ToIndex(primaryKeyValue)] == null)
                    {
                        break;
                    }
                    dt.LoadDataRow(ParseColsType(objs, colsHash), true);

                }

                for (int i = 0; i < ((object[])excelObjctData[0]).Length; i++)
                {
                    if (!colsHash.ContainsKey(ToTagName(i)))
                    {
                        dt.Columns.Remove(ToTagName(i));
                    }
                }
            }
            return dt;
        }
开发者ID:porter1130,项目名称:C-A,代码行数:33,代码来源:ExcelService.cs

示例9: ToDataSet

        /// <summary> 
        /// 集合装换DataSet 
        /// </summary> 
        /// <param name="list">集合</param> 
        /// <returns></returns> 
        /// 2008-08-01 22:08 HPDV2806 
        public static DataSet ToDataSet(IList p_List)
        {
            DataSet result = new DataSet();
            DataTable _DataTable = new DataTable();
            if (p_List.Count > 0)
            {
                PropertyInfo[] propertys = p_List[0].GetType().GetProperties();
                foreach (PropertyInfo pi in propertys)
                {
                    _DataTable.Columns.Add(pi.Name, pi.PropertyType);
                }

                for (int i = 0; i < p_List.Count; i++)
                {
                    ArrayList tempList = new ArrayList();
                    foreach (PropertyInfo pi in propertys)
                    {
                        object obj = pi.GetValue(p_List[i], null);
                        tempList.Add(obj);
                    }
                    object[] array = tempList.ToArray();
                    _DataTable.LoadDataRow(array, true);
                }
            }
            result.Tables.Add(_DataTable);
            return result;
        }
开发者ID:yuzhiping,项目名称:HyCtbuEco,代码行数:33,代码来源:IListDataSet.cs

示例10: ConverDataReaderToDataTable

 public static DataTable ConverDataReaderToDataTable(IDataReader reader)
 {
     if (reader == null)
     {
         return null;
     }
     DataTable table = new DataTable
     {
         Locale = CultureInfo.InvariantCulture
     };
     int fieldCount = reader.FieldCount;
     for (int i = 0; i < fieldCount; i++)
     {
         table.Columns.Add(reader.GetName(i), reader.GetFieldType(i));
     }
     table.BeginLoadData();
     object[] values = new object[fieldCount];
     while (reader.Read())
     {
         reader.GetValues(values);
         table.LoadDataRow(values, true);
     }
     table.EndLoadData();
     return table;
 }
开发者ID:bookxiao,项目名称:orisoft,代码行数:25,代码来源:DbHelperSQL.cs

示例11: DataReaderToDataSet

        public static DataSet DataReaderToDataSet(IDataReader reader)
        {
            var ds = new DataSet();
            DataTable table;
            do
            {
                int fieldCount = reader.FieldCount;
                table = new DataTable();
                for (int i = 0; i < fieldCount; i++)
                {
                    table.Columns.Add(reader.GetName(i), reader.GetFieldType(i));
                }
                table.BeginLoadData();
                var values = new Object[fieldCount];
                while (reader.Read())
                {
                    reader.GetValues(values);
                    table.LoadDataRow(values, true);
                }
                table.EndLoadData();

                ds.Tables.Add(table);

            } while (reader.NextResult());
            reader.Close();
            return ds;
        }
开发者ID:samnuriu13,项目名称:APIXERP,代码行数:27,代码来源:Util.cs

示例12: load_from_excel_file

        public void load_from_excel_file(string path, int bufferSize, out float[] channel_2, out float[] timeCoordinate, out int count_channel_2)
        {
            var workbook = ExcelLibrary.SpreadSheet.Workbook.Load(path);
            var worksheet = workbook.Worksheets[0];
            var cells = worksheet.Cells;
            var dataTable = new DataTable("datatable");
            // добавить столбцы в таблицу
            dataTable.Columns.Add("force");
            dataTable.Columns.Add("time");
            // добавить строки в таблицу
            for (int rowIndex = cells.FirstRowIndex + 1; rowIndex <= cells.LastRowIndex; rowIndex++)
            {
                var values = new List<string>();
                foreach (var cell in cells.GetRow(rowIndex))
                {
                    values.Add(cell.Value.StringValue);
                }

                dataTable.LoadDataRow(values.ToArray(), true);
            }

            DataRow[] dr = dataTable.Select();
            channel_2 = new float[bufferSize];
            timeCoordinate = new float[bufferSize];
            count_channel_2 = 0;

            foreach (DataRow r in dr)
            {
                channel_2[count_channel_2] = Int16.Parse((string)r[0]);
                timeCoordinate[count_channel_2] = Single.Parse((string)r[1]);
                count_channel_2++;
            }
        }
开发者ID:K0lyuchiy,项目名称:Tass,代码行数:33,代码来源:Excel_Interface.cs

示例13: ListToDataTable

        public static DataTable ListToDataTable(IList ResList)
        {
            DataTable TempDT = new DataTable();

            System.Reflection.PropertyInfo[] p = ResList[0].GetType().GetProperties();
            foreach (System.Reflection.PropertyInfo pi in p)
            {
                TempDT.Columns.Add(pi.Name, System.Type.GetType(pi.PropertyType.ToString()));
            }

            for (int i = 0; i < ResList.Count; i++)
            {
                IList TempList = new ArrayList();
                foreach (System.Reflection.PropertyInfo pi in p)
                {
                    object oo = pi.GetValue(ResList[i], null);
                    TempList.Add(oo);
                }

                object[] itm = new object[p.Length];
                for (int j = 0; j < TempList.Count; j++)
                {
                    itm.SetValue(TempList[j], j);
                }
                TempDT.LoadDataRow(itm, true);
            }
            return TempDT;
        }
开发者ID:CalvertYang,项目名称:webinspector,代码行数:28,代码来源:MapSetup.cs

示例14: Create

    public void Create(ConstructGen<double> candleData_, int openIndex_ = 0, int highIndex_ = 1, int lowIndex_ = 2, int closeIndex_ = 3, int setupLength_=9, int countdownLength_=13)
    {
      var dt = new DataTable();
      dt.Rows.Clear();
      dt.Columns.Clear();

      dt.Columns.Add("Date", typeof(DateTime));
      dt.Columns.Add("Open", typeof(double));
      dt.Columns.Add("High", typeof(double));
      dt.Columns.Add("Low", typeof(double));
      dt.Columns.Add("Close", typeof(double));
      dt.Columns.Add("Volume", typeof(double));

      ultraChart1.DataSource = dt;

      var closes = candleData_.GetColumnValuesAsDDC(closeIndex_);
      var range = closes.Data.Max() - closes.Data.Min();
      var cellHeight = range/10d;


      var setupStarts = DeMarkAnalysis.GetSetups(candleData_,openIndex_,highIndex_,lowIndex_,closeIndex_,setupLength_);
      DeMarkAnalysis.AddCountdowns(candleData_, setupStarts,openIndex_,highIndex_,lowIndex_,closeIndex_,setupLength_,countdownLength_);


      for (int i = 0; i < candleData_.Dates.Count; ++i)
      {
        var date = candleData_.Dates[i];

        var arr = candleData_.GetValues(date);
        dt.LoadDataRow(new object[]
        {
          date,
          arr[openIndex_],
          arr[highIndex_],
          arr[lowIndex_],
          arr[closeIndex_],
          0d
        }, true);

        foreach(var mark in setupStarts)
        {
          addAnnotations(date, mark, i, cellHeight, arr,openIndex_,highIndex_,lowIndex_,closeIndex_);
        }
      }

      EstablishDefaultTooltip(hash =>
      {
        int rowNumber = (int) hash["DATA_ROW"];

        return string.Format("{0} Open: {1}, High: {2}, Low: {3}, Close: {4}",
          ((DateTime) dt.Rows[rowNumber]["Date"]).ToString("dd-MMM-yyyy"),
          ((double) dt.Rows[rowNumber]["Open"]).ToString(CultureInfo.InvariantCulture),
          ((double)dt.Rows[rowNumber]["High"]).ToString(CultureInfo.InvariantCulture),
          ((double)dt.Rows[rowNumber]["Low"]).ToString(CultureInfo.InvariantCulture),
          ((double)dt.Rows[rowNumber]["Close"]).ToString(CultureInfo.InvariantCulture)
          ).Replace(",", System.Environment.NewLine);

      });
    }
开发者ID:heimanhon,项目名称:researchwork,代码行数:59,代码来源:DeMarkChart3.cs

示例15: SimpleDataTable

 public static DataTable SimpleDataTable()
 {
     DataTable dataTable = new DataTable();
     dataTable.Columns.Add("First");
     dataTable.Columns.Add("2nd");
     dataTable.Columns.Add("3");
     dataTable.LoadDataRow(new object[] { "a", "b", "c" }, false);
     return dataTable;
 }
开发者ID:kevinbosman,项目名称:habanero,代码行数:9,代码来源:CsvTestsSamples.cs


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