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


C# Database.Open方法代码示例

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


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

示例1: GetById

        //Haal de gegevens op aan de hand van het ID en geeft van het spoor alle gegevens terug.
        public static Spoor GetById(int id)
        {
            Spoor spoor = null;

            Database db = new Database();

            try
            {
                db.CreateCommand("SELECT * FROM spoor WHERE id = :id");
                db.AddParameter("id", id);
                db.Open();
                db.Execute();
                OracleDataReader dr = db.DataReader;

                if (dr.HasRows)
                {
                    dr.Read();

                    spoor = new Spoor(dr.GetValueByColumn<int>("id"), dr.GetValueByColumn<int>("nummer"),dr.GetValueByColumn<int>("lijnnummer1"), dr.GetValueByColumn<int>("lijnnummer2"));
                }
            }
            catch (Exception ex)
            {
                throw ex;
            }
            finally
            {
                db.Close();
            }

            return spoor;
        }
开发者ID:Tomickescape,项目名称:TVS,代码行数:33,代码来源:Spoor.cs

示例2: GetLoanedForUser

        public DataTable GetLoanedForUser(int userId)
        {
            try
            {

                using (Database db = new Database(GlobalObjects.CONNECTION_STRING))
                {
                    db.Open();
                    string sql;
                    int ret = 0;
                    DataTable oTable = new DataTable();
                    sql = "Dashboard_GetLoanedForUser";
                    db.ExecuteCommandReader(sql,
                        new string[] { "@id" },
                        new DbType[] { DbType.Int32 },
                        new object[] { userId },
                        out ret, ref oTable, CommandTypeEnum.StoredProcedure);

                    return oTable;
                }

            }
            catch (Exception ex)
            {
                throw ex;
            }
        }
开发者ID:jeromefurog,项目名称:moneyloandering,代码行数:27,代码来源:DashboardService.cs

示例3: GetAll

        public DataView GetAll(string query, int type)
        {
            try
            {
                using (Database db = new Database(GlobalObjects.CONNECTION_STRING))
                {

                    db.Open();
                    int ret = 0;
                    DataTable oTable = new DataTable();
                    string sql = "GetWithdrawals";
                    db.ExecuteCommandReader(sql,
                        new string[] { "@query" },
                        new DbType[] { DbType.String },
                        new object[] { query },
                        out ret, ref oTable, CommandTypeEnum.StoredProcedure);

                    return Utility.FilterDataTable(FormalFormatTable(oTable), "type=" + type.ToString());

                }
            }
            catch (Exception ex)
            {

                throw ex;
            }
        }
开发者ID:jeromefurog,项目名称:moneyloandering,代码行数:27,代码来源:WithdrawalService.cs

示例4: GetAll

        public DataView GetAll(string query)
        {
            try
            {
                using (Database db = new Database(GlobalObjects.CONNECTION_STRING))
                {

                    db.Open();
                    int ret = 0;
                    DataTable oTable = new DataTable();
                    string sql = "GetInvestors";
                    db.ExecuteCommandReader(sql,
                        new string[] { "@query" },
                        new DbType[] { DbType.String },
                        new object[] { query },
                        out ret, ref oTable, CommandTypeEnum.StoredProcedure);

                    return FormalFormatTable(oTable).DefaultView;

                }
            }
            catch (Exception ex)
            {

                throw ex;
            }
        }
开发者ID:jeromefurog,项目名称:moneyloandering,代码行数:27,代码来源:InvestorService.cs

示例5: Authenticate

        public UserEntity Authenticate(string systemID, string password)
        {
            try
            {

                UserEntity user = new UserEntity();
                int ret = 0;
                DataTable oTable = new DataTable();

                using (Database db = new Database(GlobalObjects.CONNECTION_STRING))
                {
                    db.Open();

                    string sql = "AuthenticateUser";
                    db.ExecuteCommandReader(sql,
                        new string[] { "@username", "@password" },
                        new DbType[] { DbType.String, DbType.String },
                        new object[] { systemID, password },
                        out ret, ref oTable, CommandTypeEnum.StoredProcedure);

                    if (oTable.Rows.Count > 0)
                    {
                        DataRow oRow = oTable.Rows[0];
                        user = SetData(oRow);

                    }
                }

                return user;
            }
            catch (Exception ex) { throw ex; }
        }
开发者ID:jeromefurog,项目名称:moneyloandering,代码行数:32,代码来源:UserService.cs

示例6: DeleteUser

        public void DeleteUser(int id)
        {
            try
            {
                using (Database db = new Database(GlobalObjects.CONNECTION_STRING))
                {
                    db.Open();
                    string sql;
                    int ret = 0;
                    DataTable oTable = new DataTable();
                    sql = "DeleteFromTable";
                    db.ExecuteCommandReader(sql,
                        new string[] { "@tablename", "@id", "@updatedby" },
                        new DbType[] { DbType.String, DbType.Int32, DbType.String },
                        new object[] { "Withdrawals", id, appUsr.UserName },
                        out ret, ref oTable, CommandTypeEnum.StoredProcedure);

                }
            }
            catch (Exception ex)
            {

                throw ex;
            }
        }
开发者ID:jeromefurog,项目名称:moneyloandering,代码行数:25,代码来源:WithdrawalService.cs

示例7: ServerInit

        protected void ServerInit()
        {
            Users = new List<User>();
            Channels = new List<Channel>();

            SetupRegex();
            SetupTimers();
            CreateDefaultChannels();

            database = new Database();
            database.Open(Config.DatabaseFilename);

            console = new User(null, true);
            console.Username = "";
        }
开发者ID:AlphaBlend,项目名称:VNet,代码行数:15,代码来源:Server.cs

示例8: 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

示例9: SearchBrevets

    /*
     * 
     * SEARCH BREVET
     * */
    public List<Brevet> SearchBrevets(String distance, String year, String location)
    {
        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 " +
                "WHERE distance = '"+distance+
                "' AND brevetdate LIKE '"+year+"%'"+
                " AND location = '"+location +
                "' 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,代码行数:48,代码来源:BrevetDAO.cs

示例10: Setup

        public void Setup()
        {
            if (File.Exists(DbName))
            {
                File.Delete(DbName);
            }
            _dataBase = Library.Instance.CreateDatabase();

            _dataBase.Open(DbName, Database.DefaultOpenMode | OpenMode.TruncateOnOpen);

            _collection = _dataBase.CreateCollection("Persons", new CollectionOptions());

            using (var tx = _collection.BeginTransaction())
            {
                _collection.Save(Person.Navalny(), false);
                _collection.Save(Person.Putin(), false);
                tx.Commit();
            }
        }
开发者ID:hendryten,项目名称:ejdb-csharp,代码行数:19,代码来源:CriterionTests.cs

示例11: ServerInit

        /// <summary>
        /// Server initialization
        /// </summary>
        protected void ServerInit()
        {
            Users = new List<User>();
            Channels = new List<Channel>();

            PacketSendBufferer.Init(Config.Network.SendBufferInterval);

            SetupRegex();
            SetupFloodDictionaries();
            SetupTimers();
            CreateDefaultChannels();
            InitCommandTables();

            database = new Database();
            database.Open(Config.DatabaseFilename);

            console = new User(null, true);
            console.RealUsername = "";
        }
开发者ID:Lynxy,项目名称:VNet,代码行数:22,代码来源:Server.cs

示例12: 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

示例13: 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

示例14: 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

示例15: DoesCutoffExist

        public bool DoesCutoffExist(int id, int loan_id, DateTime loandate)
        {
            try
            {
                using (Database db = new Database(GlobalObjects.CONNECTION_STRING))
                {
                    db.Open();
                    string sql;
                    int ret = 0;
                    DataTable oTable = new DataTable();
                    sql = "DoesCutoffExist";
                    db.ExecuteCommandReader(sql,
                        new string[] { "@loanid", "@id", "@date" },
                        new DbType[] { DbType.Int32, DbType.Int32, DbType.Date },
                        new object[] { loan_id, id, loandate },
                        out ret, ref oTable, CommandTypeEnum.StoredProcedure);

                    if (oTable.Rows.Count > 0) { return true; }

                    return false;
                }
            }
            catch (Exception ex) { throw ex; }
        }
开发者ID:jeromefurog,项目名称:moneyloandering,代码行数:24,代码来源:PayableService.cs


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