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


C# Database.Close方法代码示例

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


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

示例1: GetById

        //haal een remise op aan de hand van een ID
        public Remise GetById(int id)
        {
            Remise remise = null;

            Database db = new Database();

            try
            {
                db.CreateCommand("SELECT * FROM remise WHERE id = :id");
                db.AddParameter("id", id);

                while (db.Read())
                {
                    remise = new Remise(db.GetValueByColumn<int>("id"), db.GetValueByColumn<int>("nummer"));
                }
            }
            catch (Exception ex)
            {
                throw ex;
            }
            finally
            {
                db.Close();
            }

            return remise;
        }
开发者ID:Tomickescape,项目名称:TVS,代码行数:28,代码来源:Remise.cs

示例2: GetById

        //Haal de gegevens op aan de hand van het IDnummer en geeft een instantie van die lijn terug.
        public Lijn GetById(int id)
        {
            Lijn lijn = null;

            Database db = new Database();

            try
            {
                db.CreateCommand("SELECT * FROM lijn WHERE id = :id");
                db.AddParameter("id", id);

                while (db.Read())
                {
                    lijn = new Lijn(db.GetValueByColumn<int>("id"), db.GetValueByColumn<int>("nummer"));
                }
            }
            catch (Exception ex)
            {
                throw ex;
            }
            finally
            {
                db.Close();
            }

            return lijn;
        }
开发者ID:Tomickescape,项目名称:TVS,代码行数:28,代码来源:Lijn.cs

示例3: GetAll

        //haal alle loggegevens op en returned een list hiervan
        public static List<Log> GetAll()
        {
            List<Log> logs = new List<Log>();

            Database db = new Database();

            try
            {
                db.CreateCommand("SELECT * FROM tram_log");
                while (db.Read())
                {
                    logs.Add(new Log(db.GetValueByColumn<int>("id"), db.GetValueByColumn<int>("tram_id"),db.GetValueByColumn<int>("segment_id"),db.GetValueByColumn<DateTime>("created")));
                }
            }
            catch (Exception ex)
            {
                throw ex;
            }
            finally
            {
                db.Close();
            }

            return logs;
        }
开发者ID:Tomickescape,项目名称:TVS,代码行数:26,代码来源:Log.cs

示例4: OnSelectedIndexChanged_data_notice

    protected void OnSelectedIndexChanged_data_notice(object sender, EventArgs e)
    {
        DropDownList n = (DropDownList)sender;
        ListViewDataItem o = n.Parent as ListViewDataItem;

        int status = int.Parse(n.SelectedValue);
        int id = int.Parse((o.FindControl("idLabel") as Label).Text);

        SqlParam data = new SqlParam { { "@id", id }, { "@status", status } };
        string sql = "UPDATE [data_notice] SET [status] = @status WHERE [id] = @id";

        Database db = new Database();
        db.Exec(sql, data);
        db.Close();
    }
开发者ID:SwimmingTiger,项目名称:ReportingSystem,代码行数:15,代码来源:Auditor.aspx.cs

示例5: OnSelectedIndexChanged_data_cardsale

    protected void OnSelectedIndexChanged_data_cardsale(object sender, EventArgs e)
    {
        RadioButtonList downlist = (RadioButtonList)sender;
        ListViewDataItem o = downlist.Parent as ListViewDataItem;

        int status = int.Parse(downlist.SelectedValue);
        int id = int.Parse((o.FindControl("idLabel") as Label).Text);

        String sql = "UPDATE [data_cardsale] SET [status] = @status WHERE [id] = @id";
        SqlParam data = new SqlParam { { "@id", id }, { "@status", status } };

        Database db = new Database();
        db.Exec(sql, data);
        db.Close();
    }
开发者ID:SwimmingTiger,项目名称:ReportingSystem,代码行数:15,代码来源:Test.aspx.cs

示例6: GetLoginRole

    public LoginRole GetLoginRole(string username, string password)
    {

        LoginRole loginRole = new LoginRole();
        loginRole.Role = null;
        IDataReader resultSet;

        try
        {
            myDatabase = new Database();
            myDatabase.Open(myConnectionString);
            String role = "";
            String sqlText =
            "SELECT role " +
            "FROM Rider " +
            "WHERE username = '" + username + "' AND password = '" + password + "'";

            resultSet = myDatabase.ExecuteQuery(sqlText);

            if (resultSet.Read() == true)
            {
                role = (String)resultSet["role"];
            }


            if (role == "user")
            {
                loginRole.Role = "user";
            }
            else if (role == "admin")
            {
                loginRole.Role = "administrator";
            }
            resultSet.Close();
            return loginRole;
        }
        catch (Exception)
        {
            return null;
        }
        finally
        {
            myDatabase.Close();
        }


    }
开发者ID:ProDoser,项目名称:randonneur_website,代码行数:47,代码来源:LoginDAO.cs

示例7: GetName

        /// <summary>
        /// 获取用户名
        /// </summary>
        /// <returns></returns>
        public static string GetName()
        {
            string sql = "SELECT username FROM userinfo WHERE [email protected]";
            SqlParam data = new SqlParam { { "@id", GetId() } };
            Database db = new Database();
            SqlDataReader reader = db.Query(sql, data);
            string name = null;

            if (reader.Read()) {
                name = (string)reader["username"];
            }

            reader.Close();
            db.Close();

            return name;
        }
开发者ID:SwimmingTiger,项目名称:ReportingSystem,代码行数:21,代码来源:User.cs

示例8: GetAllBrevets

    public List<Brevet> GetAllBrevets()
    {
        List<Brevet> brevetList = new List<Brevet>();
        IDataReader resultSet;
        try
        {
            myDatabase = new Database();
            myDatabase.Open(myConnectionString);

            string sqlText =
                "SELECT brevetid, distance, brevetdate, location, climbing " +
                "FROM brevet " +
                "ORDER BY brevetdate;";

            resultSet = myDatabase.ExecuteQuery(sqlText);
            while (resultSet.Read() == true)
            {
                Brevet brevet = new Brevet();
                brevet.BrevetId = (int)resultSet["brevetid"];
                
                brevet.BrevetDate = (DateTime)resultSet["brevetdate"];
                brevet.Location = (String)resultSet["location"];
                brevet.Climbing = (int)resultSet["climbing"];

                brevet.Distance = (int)resultSet["distance"];
                brevetList.Add(brevet);
            }

            resultSet.Close();
            return brevetList;
        }

        catch (Exception)
        {
            return null;
        }
        finally
        {
            myDatabase.Close();
        }
    }
开发者ID:ProDoser,项目名称:randonneur_website,代码行数:41,代码来源:BrevetDAO.cs

示例9: LoadComponents

        private void LoadComponents()
        {
            ContentPlaceHolder mpContentPlaceHolder;
            mpContentPlaceHolder =
              (ContentPlaceHolder)Master.FindControl("MainContent");

            Database obj = new Database();
            try
            {
                obj.Connect();
                obj.Query("SELECT * FROM ComponentTypes");

                if (obj.rdr.HasRows == true)
                {
                    while (obj.rdr.Read())
                    {
                        HtmlGenericControl li = new HtmlGenericControl("li");
                        if (mpContentPlaceHolder != null)
                        {
                            mpContentPlaceHolder.FindControl("tiles").Controls.Add(li);
                        }
                        HtmlGenericControl anchor = new HtmlGenericControl("a");
                        anchor.Attributes.Add("href", "ComponentList.aspx/?Type=" + Convert.ToString(obj.rdr["CompTypeID"].ToString()));
                        anchor.InnerHtml = "<div class=\"nailthumb-container\"><img src=\"../assets/img/CompTypeThumbs/" + Convert.ToString(obj.rdr["CompTypeThumbImage"].ToString()) + "\"></div>";
                        li.Controls.Add(anchor);
                        // li.InnerHtml = "<img src=\"../assets/img/Furniture/" + Convert.ToString(obj.rdr["CompTypeThumbImage"].ToString()) + "\">";
                        li.Attributes.Add("onclick", "");
                    }
                }
            }

            catch (Exception ex)
            {
                // MessageBox.Show(ex.Message.ToString() + " : " + ex.StackTrace.ToString(), "Load Error");
            }
            finally
            {
                obj.Close();
            }
        }
开发者ID:wiechars,项目名称:EF,代码行数:40,代码来源:ComponentTypes.aspx.cs

示例10: GetAllClubs

    public List<Club> GetAllClubs()
    {
        List<Club> clubList = new List<Club>();
        IDataReader resultSet;
        try
        {
            myDatabase = new Database();
            myDatabase.Open(myConnectionString);

            string sqlText =
                "SELECT clubName, city, clubid, email " +
                "FROM Club " +
                "ORDER BY clubName;";

            resultSet = myDatabase.ExecuteQuery(sqlText);
            while (resultSet.Read() == true)
            {
                Club club = new Club();
                club.ClubId = (int)resultSet["clubid"];
                club.ClubName = (String)resultSet["clubName"];
                club.ClubCity = (String)resultSet["city"];
                club.ClubEmail = (String)resultSet["email"];

                clubList.Add(club);
            }

            resultSet.Close();
            return clubList;
        }

        catch (Exception)
        {
            return null;
        }
        finally
        {
            myDatabase.Close();
        }
    }
开发者ID:ProDoser,项目名称:randonneur_website,代码行数:39,代码来源:ClubDAO.cs

示例11: GetAllBrevet_Raider

    public List<Brevet_Raider> GetAllBrevet_Raider()
    {
        List<Brevet_Raider> brevet_RiderList = new List<Brevet_Raider>();
        IDataReader resultSet;
        try
        {
            myDatabase = new Database();
            myDatabase.Open(myConnectionString);

            string sqlText =
                "SELECT * FROM Brevet_Rider"+
                "ORDER BY brevetid";

            resultSet = myDatabase.ExecuteQuery(sqlText);
            while (resultSet.Read() == true)
            {
                Brevet_Raider brevet = new Brevet_Raider();
                brevet.RiderId = (int)resultSet["riderid"];
                brevet.BrevetId = (int)resultSet["brevetid"];
                brevet.IsCompleated = (String)resultSet["isCompleated"];
                brevet.FinishingTime = (String)resultSet["finishingtime"];


                brevet_RiderList.Add(brevet);
            }

            resultSet.Close();
            return brevet_RiderList;
        }

        catch (Exception)
        {
            return null;
        }
        finally
        {
            myDatabase.Close();
        }
    }
开发者ID:ProDoser,项目名称:randonneur_website,代码行数:39,代码来源:Brever_RiderDAO.cs

示例12: dateRange

        /// <summary>
        /// 返回指定数据表指定日期字段中年份的范围,若表中无数据,则返回(0, -1)
        /// </summary>
        /// <param name="table">表名</param>
        /// <param name="field">字段名</param>
        /// <returns>Tuple<int, int>(最小年份, 最大年份),若表中无数据,返回(0, -1)</returns>
        public static Tuple<int, int> dateRange(string table, string field)
        {
            int min = 0;
            int max = -1;

            string sql = "select min(year(" + field + ")) as [min], max(year(" + field + ")) as [max] from " + table;

            Database db = new Database();
            SqlDataReader reader = db.Query(sql);

            if (reader.Read()) {
                if (!(reader["min"] is DBNull) && !(reader["max"] is DBNull))
                {
                    min = (int)reader["min"];
                    max = (int)reader["max"];
                }
            }

            reader.Close();
            db.Close();

            return new Tuple<int, int>(min, max);
        }
开发者ID:SwimmingTiger,项目名称:ReportingSystem,代码行数:29,代码来源:DataProvider.cs

示例13: ProcessRequest

        public void ProcessRequest(HttpContext context)
        {
            var accessToken = context.Request["accessToken"].Split('&')[0].Split('=')[1];
            string uid = context.Request["uid"];
            FacebookInteraction.access_token = accessToken;
            context.Session["token"] = accessToken;
            context.Session["uid"] = uid;
            Database database = new Database("b81ca2da-f0ca-4968-b9ef-a147009a4ef4.mysql.sequelizer.com",
                "dbb81ca2daf0ca4968b9efa147009a4ef4", "lizeabvjtqokfima", "qauWLTF4Db7umBPvvyy5LPYAzjLvtFMJKNKnbahQUaN7eEks6ndW4FvHi3vAhkH6");
            MySqlCommand command = database.CreateCommand();
            command.CommandType = System.Data.CommandType.Text;
            string query = "SELECT COUNT(*) FROM facebook.users WHERE user_id = '" + uid + "'";
            database.Open();
            bool isNewUser;
            if (Convert.ToInt32(database.ExecuteScalar(query, command)) == 0)
            {
                query = "INSERT INTO facebook.users VALUES('" + uid + "', '" + accessToken + "', '" + DateTime.Now.ToString("yyyy-MM-dd HH:mm:ss") + "')";
                isNewUser = true;
            }
            else
            {
                query = "UPDATE facebook.users SET token = '" + accessToken + "' WHERE user_id = '" + uid + "'";
                isNewUser = false;
            }
            database.ExecuteNonQuery(query, command);

            database.Close();
            if (isNewUser)
            {
                context.Response.Redirect("../FirstTimeIndex.aspx");
            }
            else
            {
                context.Response.Redirect("../Search/Search.aspx");
            }
        }
开发者ID:camillu,项目名称:FacebookSearchEngine,代码行数:36,代码来源:LoginHandler.ashx.cs

示例14: ChangeStatus

        public void ChangeStatus(Status status)
        {
            Database db = new Database();

            try
            {
                db.CreateCommand("UPDATE tram SET status = :status WHERE id = :id");
                db.AddParameter("status", status.ToString());
                db.AddParameter("id", Id);
                db.Execute();

                Status = status;
            }
            catch (Exception ex)
            {
                throw ex;
            }
            finally
            {
                db.Close();
            }
        }
开发者ID:Tomickescape,项目名称:TVS,代码行数:22,代码来源:Tram.cs

示例15: ChangeSegment

        public void ChangeSegment(Segment segment)
        {
            Database db = new Database();

            try
            {
                db.CreateCommand("UPDATE tram SET segment_id = :segmentId WHERE id = :id");
                db.AddParameter("segmentId", segment != null ? segment.Id : 0);
                db.AddParameter("id", Id);
                db.Open();
                db.Execute();

                Log(segment);
            }
            catch (Exception ex)
            {
                throw ex;
            }
            finally
            {
                db.Close();
            }
        }
开发者ID:Tomickescape,项目名称:TVS,代码行数:23,代码来源:Tram.cs


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