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


C# Data.DataTable类代码示例

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


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

示例1: Insert

		public Int16 Insert(ParkingRateDetails Details)
		{
			try 
			{
                Details.CreatedByName = Details.ParkingRateID == 0 ? Details.CreatedByName : Details.LastUpdatedByName;

                Save(Details);

                string SQL = "SELECT LAST_INSERT_ID();";

                MySqlCommand cmd = new MySqlCommand();
                cmd.CommandType = System.Data.CommandType.Text;
                cmd.CommandText = SQL;

                System.Data.DataTable dt = new System.Data.DataTable("LAST_INSERT_ID");
                base.MySqlDataAdapterFill(cmd, dt);
                

                Int16 iID = 0;
                foreach (System.Data.DataRow dr in dt.Rows)
                {
                    iID = Int16.Parse(dr[0].ToString());
                }

				return iID;
			}

			catch (Exception ex)
			{
				throw base.ThrowException(ex);
			}	
		}
开发者ID:marioricci,项目名称:erp-luma,代码行数:32,代码来源:ParkingRates.cs

示例2: bindgrid

        public void bindgrid()
        {
            System.Data.DataTable dt = new System.Data.DataTable();

            if (OboutDropDownList1.SelectedValue == "Clients")
            {
                dt = Functions.DB.GetCustomers();
            }
            else if (OboutDropDownList1.SelectedValue == "Sales Reps")
            {
                dt = Functions.DB.GetSalesReps();
            }

            Grid1.DataSource = dt;
            Grid1.DataBind();
            string ID = string.Empty;
            SqlDataSource src = new SqlDataSource();
            if (dt.Rows.Count > 0)
            {
                System.Collections.Hashtable al = Grid1.Rows[0].ToHashtable();
                ID = al["ID"].ToString();
            }
            if (OboutDropDownList1.SelectedValue == "Clients")
            {
                src = Functions.DB.GetSQLDataSource2("SELECT top 1 *  FROM CLIENT_DAT Where ID='" + ID + "'");
            }
            else if (OboutDropDownList1.SelectedValue == "Sales Reps")
            {
                src = Functions.DB.GetSQLDataSource("SELECT top 1 *  FROM SalesReps Where ID=" + ID);
            }

            // SuperForm1.DefaultMode = DetailsViewMode.ReadOnly;
            SuperForm1.DataSource = src;
            SuperForm1.DataBind();
        }
开发者ID:Truplaya53,项目名称:CompassNet,代码行数:35,代码来源:DataUpdate.aspx.cs

示例3: BindDemo

        private void BindDemo()
        {
            ITwitterAuthorizer autentikasi = GetInformasiKredensial();

            var TwitterDataContext = new TwitterContext(autentikasi);

            var hasilpencarian = (from search in TwitterDataContext.Search
                                  where search.Type == SearchType.Search &&
                                        search.Query == "#PERSIB" &&
                                        search.ResultType == ResultType.Recent &&
                                        search.PageSize == 100
                                  select search)
                .Single();

            System.Data.DataTable dt = new System.Data.DataTable();
            dt.Columns.Add("name");
            dt.Columns.Add("text");

            foreach (SearchEntry item in hasilpencarian.Results)
            {
                dt.Rows.Add(item.FromUser, item.Text);
            }

            gvMain.DataSource = dt;
            gvMain.DataBind();
        }
开发者ID:go2ismail,项目名称:JurusTwitterAPISourceCode,代码行数:26,代码来源:Default.aspx.cs

示例4: Main

        static void Main(string[] args)
        {
            MethodInfo[] ms = typeof(object).GetMethods();
            foreach (MethodInfo m in ms)
            {
                Console.WriteLine(m.ToString());
            }
            Console.WriteLine(FiboCalculator.Equals(10, 0.0));
            Console.WriteLine("***Fun With Conversions ***");
            int myInt = 12345678;
            myInt.DisplayDefiningAssembly();
            System.Data.DataTable dt = new System.Data.DataTable();
            dt.DisplayDefiningAssembly();

           Console.WriteLine( myInt.ReverseDigits());
           Console.WriteLine("扩展接口测试");
           string[] data = { "Wow", "this", "is ", "sort", "of", "annoying", "but", "in", "a", "weird", "way", "fun" };
           data.PrintDataAndBeep();
                Rectangle r=new Rectangle(5,4);
            Console.WriteLine(r.ToString());
            r.Draw();
            Square s = (Square)r;
            Console.WriteLine(s.ToString());
            s.Draw();
            Console.WriteLine(GC.GetTotalMemory(false)+"---"+GC.MaxGeneration);
          //  Console.ReadLine();
            BuildAnonType("BWM", "red", 1234);
        }
开发者ID:red201432,项目名称:CSharpLearn,代码行数:28,代码来源:Program.cs

示例5: PopulateEmployerGroupDDL

        public void PopulateEmployerGroupDDL()
        {
            dbProcedures db = new dbProcedures();

            try
            {
                System.Data.SqlClient.SqlCommand sqlCmd = new System.Data.SqlClient.SqlCommand("SELECT DISTINCT EmployerGroup FROM tbl_Members ORDER BY EmployerGroup", new db().SqlConnection);
                sqlCmd.CommandType = System.Data.CommandType.Text;

                System.Data.DataTable loadReaderdata = new System.Data.DataTable();
                loadReaderdata.Load(sqlCmd.ExecuteReader());

                ddlEmployerGroup.DataSource = loadReaderdata;
                ddlEmployerGroup.DataTextField = "EmployerGroup";
                ddlEmployerGroup.DataValueField = "EmployerGroup";
                ddlEmployerGroup.DataBind();

                ddlEmployerGroup.Items.Insert(0, new ListItem("", ""));
                ddlEmployerGroup.SelectedIndex = 0;

            }
            catch (Exception ex)
            {
                db.LogAction("", "Error", "Error loading Members UI page. " + ex.Message.ToString());
            }

            db.Close();
        }
开发者ID:reagan83,项目名称:EOBSystemAdmin,代码行数:28,代码来源:Members.aspx.cs

示例6: GetCSVTest

        public void GetCSVTest()
        {
            var datatable = new System.Data.DataTable();
            datatable.Columns.Add("Col1", typeof (string));
            datatable.Columns.Add("Co12", typeof (string));
            datatable.Rows.Add("A", "ł");
            datatable.Rows.Add("ą", "ä");

            string failure = null;
            var thread = new System.Threading.Thread(() =>
                                                         {
                                                             var dataobject =
                                                                 System.Windows.Forms.Clipboard.GetDataObject();
                                                             Isotope.Clipboard.ClipboardUtil.SetDataCSVFromTable(
                                                                 dataobject, datatable);
                                                             System.Windows.Forms.Clipboard.SetDataObject(dataobject);

                                                             var out_csv = Isotope.Clipboard.ClipboardUtil.GetCSV();
                                                             System.Windows.Forms.Clipboard.Clear();
                                                         });
            thread.SetApartmentState(System.Threading.ApartmentState.STA);
            thread.Start();
            thread.Join();
            if (failure != null)
            {
                Assert.Fail();
            }
        }
开发者ID:saveenr,项目名称:saveenr,代码行数:28,代码来源:ClipboardUtilTest.cs

示例7: TestOracleConn

//        public string CreateMYSQLModel(string DBName, string NameSpaceName, string TableName, string outputFilePath)
//        {
//            if (string.IsNullOrEmpty(DBName) || string.IsNullOrEmpty(NameSpaceName) || string.IsNullOrEmpty(TableName) || string.IsNullOrEmpty(outputFilePath))
//                return "";
//            Session.Session mysql = Session.SessionFactory.GetMySQL();

//            List<TableModel> tbs = mysql.FindAll<TableModel>(@"SELECT COLUMN_NAME,IS_NULLABLE,DATA_TYPE,CHARACTER_MAXIMUM_LENGTH,COLUMN_COMMENT
// FROM information_schema.COLUMNS WHERE TABLE_SCHEMA='" + DBName + "' AND TABLE_NAME='" + TableName + "' ;");

//            List<KEYModel> keys = mysql.FindAll<KEYModel>(@"SELECT b.COLUMN_NAME,b.DATA_TYPE FROM information_schema.KEY_COLUMN_USAGE a
// inner join information_schema.COLUMNS b on a.TABLE_SCHEMA=b.TABLE_SCHEMA and a.COLUMN_NAME=b.COLUMN_NAME and a.TABLE_NAME=b.TABLE_NAME
// WHERE a.TABLE_SCHEMA='" + DBName + "'  AND a.TABLE_NAME='" + TableName + "' and a.CONSTRAINT_NAME='PRIMARY'; ");

//            return OutPutStr(tbs, keys, NameSpaceName, TableName, outputFilePath);
//        }

        public string TestOracleConn()
        {

            //Session.Session oracle = Session.SessionFactory.GetOracle();

            //Session.Session sql = Session.SessionFactory.GetSQLServer();


            System.Data.DataTable sds = new System.Data.DataTable();
            //sds = oracle.FindAll("select * from INFORMATION ").Tables[0];

            //List<CONFERENCE> tbs = sql.FindAll<CONFERENCE>(@"SELECT * FROM Conference");
            //List<INFORMATION_Oracle> tbs2 = oracle.FindAll<INFORMATION_Oracle>(@"SELECT * FROM INFORMATION");


            int isOk = 0;
            //for (int i = 0; i < tbs.Count; i++)
            //{
                //ParamMap param = oracle.newMap();
                //param.Add("CONFERENCE_ID", tbs[i].ConferenceId);
                //param.Add("CONTENTS", tbs[i].Contents);
                //string sqlStr = "update CONFERENCE set CONTENTS=:CONTENTS  where CONFERENCE_ID=:CONFERENCE_ID ";
                // > 0;

                //CONFERENCE_Oracle o_info = oracle.FindByID<CONFERENCE_Oracle>(tbs[i].ConferenceId.ToString());
                //o_info.CONTENTS = tbs[i].Contents;
                //isOk += oracle.Update<CONFERENCE_Oracle>(o_info);

                //    oracle.ExcuteSQL(sqlStr, param);
                //o_info.INFO_ID = "2015060916531897637858e973c8bb9";
           // }
            return isOk.ToString();
        }
开发者ID:lee8775,项目名称:DotNetRESTful,代码行数:49,代码来源:Tools.cs

示例8: DataReaderToDataTable

		public System.Data.DataTable DataReaderToDataTable(MySqlDataReader Reader)
		{
			System.Data.DataTable dt = new System.Data.DataTable();
			System.Data.DataColumn dc;
			System.Data.DataRow dr;
			ArrayList arr = new ArrayList();
			int i;

			for(i=0;i<Reader.FieldCount;i++)
			{
				dc = new System.Data.DataColumn();

				dc.ColumnName = Reader.GetName(i);					
				arr.Add(dc.ColumnName);

				dt.Columns.Add(dc);
			}
			
			while(Reader.Read())
			{
				dr = dt.NewRow();

				for (i=0;i<Reader.FieldCount;i++)
				{
					dr[(string)arr[i]] = Reader[i].ToString();
				}
				dt.Rows.Add(dr);
			}

			Reader.Close();
			return dt;
		}
开发者ID:marioricci,项目名称:erp-luma,代码行数:32,代码来源:DataClass.cs

示例9: Insert

		public Int64 Insert(ProductGroupUnitsMatrixDetails Details)
		{
			try 
			{
                Save(Details);

                string SQL = "SELECT LAST_INSERT_ID();";
	 			
				MySqlCommand cmd = new MySqlCommand();
				cmd.CommandType = System.Data.CommandType.Text;
				cmd.CommandText = SQL;

                System.Data.DataTable dt = new System.Data.DataTable("LAST_INSERT_ID");
                base.MySqlDataAdapterFill(cmd, dt);

                Int64 iID = 0;
                foreach (System.Data.DataRow dr in dt.Rows)
                {
                    iID = Int64.Parse(dr[0].ToString());
                }					

				return iID;
			}

			catch (Exception ex)
			{
				throw base.ThrowException(ex);
			}	
		}
开发者ID:marioricci,项目名称:erp-luma,代码行数:29,代码来源:ProductGroupUnitsMatrix.cs

示例10: calculateStringOperation

        private static string calculateStringOperation(string[] temp)
        {
            // First things first!
            string operationString = "";
            string tempVar;
            bool errorFlag = false;

            for (int i = 0; i < temp.Length; i++)
            {
            if (temp[i].Equals(".add.")) { temp[i] = " + "; }
            else if (temp[i].Equals(".sub.")) { temp[i] = " - "; }
            else if (temp[i].Equals(".mul.")) { temp[i] = " * "; }
            else if (temp[i].Equals(".div.")) { temp[i] = " / "; }
            else if (isVariableName(temp[i])) {
                if (variables.ContainsKey(temp[i])) { variables.TryGetValue(temp[i], out tempVar); temp[i] = tempVar; }
                else if (!variables.ContainsKey(temp[i])) { errorFlag = true; }
            }
            else if (isString(temp[i])) { temp[i] = temp[i].Replace('"', '\''); }
            }

            foreach (string s in temp) { operationString += s; }
            //Console.WriteLine(operationString);
            if (!errorFlag)
            {
            var result = new System.Data.DataTable().Compute(operationString, null).ToString();
            //ExpressionEval expr = new ExpressionEval(operationString);
            //object result = expr.Evaluate();
            //Console.WriteLine("Test: " + result);
            return result; //(string)result;
            }
            else
            {
            return null;
            }
        }
开发者ID:TakoArishi,项目名称:LAOInterpreter,代码行数:35,代码来源:LAOInterpreter.cs

示例11: GetAllBenchmarks

        private System.Data.DataTable GetAllBenchmarks()
        {
            HtmlAgilityPack.HtmlWeb web = new HtmlAgilityPack.HtmlWeb();
            //HtmlAgilityPack.HtmlDocument doc = new HtmlAgilityPack.HtmlDocument(); doc.Load(@"");
            HtmlAgilityPack.HtmlDocument doc = web.Load(@"http://benchmarksgame.alioth.debian.org/");

            System.Data.DataTable dt = new System.Data.DataTable();

            dt.Columns.Add("Name", typeof(string));
            dt.Columns.Add("Url", typeof(string));

            System.Data.DataRow dr = null;

            foreach (HtmlAgilityPack.HtmlNode link in doc.DocumentNode.SelectNodes("//section[1]//li/a[@href]"))
            {
                dr = dt.NewRow();
                // System.Console.WriteLine(link);
                dr["Name"] = System.Web.HttpUtility.HtmlDecode(link.InnerText);
                dr["Url"] = link.Attributes["href"].Value;

                dt.Rows.Add(dr);
            } // Next link

            System.Data.DataView dv = dt.DefaultView;
            dv.Sort = "Name ASC";
            System.Data.DataTable sortedDT = dv.ToTable();

            return sortedDT;
        }
开发者ID:ststeiger,项目名称:AliothBenchmarkDataExtract,代码行数:29,代码来源:Form1.cs

示例12: GetData

        private System.Data.DataTable GetData(int city, string lang)
        {
            try
            {
                SqlConnection myConnection = new SqlConnection("user id=Uib;" +
                                     "password=Uib;server=localhost;" +
                                     "Trusted_Connection=yes;" +
                                     "database=Uib; " +
                                     "connection timeout=30");
                myConnection.Open();
                var command = new SqlCommand("GET_HOTELS_BY_CITY", myConnection);
                command.CommandType = System.Data.CommandType.StoredProcedure;
                command.Parameters.AddWithValue("@city", city);
                command.Parameters.AddWithValue("@lang", lang);
                SqlDataReader reader = command.ExecuteReader();
                var dataTable = new System.Data.DataTable();

                dataTable.Load(reader);
                reader.Close();
                myConnection.Close();
                return dataTable;
            }
            catch (Exception e)
            {
                Console.WriteLine(e.ToString());
            }
            return null;
        }
开发者ID:LogitravelUIB,项目名称:Logitravel-Mvc,代码行数:28,代码来源:HotelController.cs

示例13: Page_Load

        protected void Page_Load(object sender, EventArgs e)
        {
            System.Data.DataTable world = new System.Data.DataTable("World Population");
            world.Columns.AddRange(new System.Data.DataColumn[] {
                new System.Data.DataColumn("Country",typeof(string)),
                new System.Data.DataColumn("Population",typeof(int))
            });
            world.Rows.Add(new object[] { "Germany", 200 });
            world.Rows.Add(new object[] { "United States", 350 });
            world.Rows.Add(new object[] { "Brazil", 250 });
            world.Rows.Add(new object[] { "Canada", 75 });
            world.Rows.Add(new object[] { "France", 290 });
            world.Rows.Add(new object[] { "Russia", 700 });
            world.Rows.Add(new object[] { "China", 1300 });
            world.Rows.Add(new object[] { "India", 1000 });

            this.GVGeoMap1.GviRegion = GoogleChartsNGraphsControls.MapRegion.World;
            this.GVGeoMap1.GviDisplayMode = GoogleChartsNGraphsControls.MapDisplayModes.Regions;
            this.GVGeoMap1.GviColors = new Color?[] { Color.Blue, Color.Cornsilk, Color.DarkMagenta, Color.DarkTurquoise, Color.FloralWhite };
            this.GVGeoMap1.DataSource = world;

            System.Data.DataTable projs = new System.Data.DataTable("US Projects");
            projs.Columns.AddRange(new System.Data.DataColumn[] {
                new System.Data.DataColumn("City",typeof(string)),
                new System.Data.DataColumn("Completion",typeof(int)),
                new System.Data.DataColumn("Comments",typeof(string))
            });
            projs.Rows.Add(new object[] { "Astoria, NY", 95, "Astoria: Almost Done" });
            projs.Rows.Add(new object[] { "Novato, CA", 35, "Novato: Just Starting" });
            projs.Rows.Add(new object[] { "Duvall, WA", 10, "Duvall: Just Starting" });

            this.GVGeoMap2.GviOptionsOverride = "{'region':'US','colors':[0xFF8747, 0xFFB581, 0xc06000], 'dataMode':'markers'}";
            this.GVGeoMap2.DataSource = projs;
        }
开发者ID:JulsMan,项目名称:googlevisualizationsdotnet,代码行数:34,代码来源:GeoMaps.aspx.cs

示例14: DataGrid_Initialized

        private void DataGrid_Initialized(object sender, System.EventArgs e)
        {
            // TODO: Delete all this code and replace it with a simple query when database is available.

            SourceDataTable = new System.Data.DataTable("Priorities");
            SourceDataTable.Columns.Add(new System.Data.DataColumn("ID", System.Type.GetType("System.Int32")));
            SourceDataTable.Columns.Add(new System.Data.DataColumn("Name", System.Type.GetType("System.String")));
            SourceDataTable.Columns.Add(new System.Data.DataColumn("Value", System.Type.GetType("System.Int32")));
            SourceDataTable.Columns.Add(new System.Data.DataColumn("Active", System.Type.GetType("System.Boolean")));

            System.Action<int, string, int, bool> AddNewRow = (id, name, value, active) =>
                {
                    var row = SourceDataTable.NewRow();
                    row["ID"] = id;
                    row["Name"] = name;
                    row["Value"] = value;
                    row["Active"] = active;
                    SourceDataTable.Rows.Add(row);
                };

            AddNewRow(1, "Haute", 1, true);
            AddNewRow(2, "Moyenne", 2, true);
            AddNewRow(3, "Faible", 3, true);

            Save();
        }
开发者ID:xeph,项目名称:LOG350.TP3,代码行数:26,代码来源:Priorities.xaml.cs

示例15: Insert

		public Int32 Insert(AccountCategoryDetails Details)
		{
			try 
			{
                Save(Details);

                string SQL = "SELECT LAST_INSERT_ID();";
				  
				MySqlCommand cmd = new MySqlCommand();
				cmd.CommandType = System.Data.CommandType.Text;
				cmd.CommandText = SQL;
				
                string strDataTableName = "tbl" + this.GetType().FullName.Split(new Char[] { '.' })[this.GetType().FullName.Split(new Char[] { '.' }).Length - 1]; System.Data.DataTable dt = new System.Data.DataTable(strDataTableName);
                base.MySqlDataAdapterFill(cmd, dt);

                Int32 iID = 0;

                foreach (System.Data.DataRow dr in dt.Rows)
                {
                    iID = Int32.Parse(dr[0].ToString());
                }

                return iID;
			}

			catch (Exception ex)
			{
				throw base.ThrowException(ex);
			}	
		}
开发者ID:marioricci,项目名称:erp-luma,代码行数:30,代码来源:AccountCategory.cs


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