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


C# Database.ExecuteQuery方法代码示例

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


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

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

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

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

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

示例5: DbTest

        private static void DbTest()
        {
            try
            {
                // Mount NAND Flash File Media
                //PersistentStorage ps = new PersistentStorage("SD");
                //ps.MountFileSystem();

                //// Format the media if it was not.
                //VolumeInfo nand = new VolumeInfo("SD");
                //if (!nand.IsFormatted)
                //{
                //    nand.Format("FAT", 0);
                //}
                // Create new database file
                Database myDatabase = new Database();
                // Open a new Database in NAND Flash
                myDatabase.Open(root + "\\myDatabase.dbs");
                //add a table
                myDatabase.ExecuteNonQuery(
                  "CREATE Table Temperature" +
                  "(Room TEXT, Time INTEGER, Value DOUBLE)");

                //add rows to table
                myDatabase.ExecuteNonQuery(
                  "INSERT INTO Temperature (Room, Time,Value) " +
                  "VALUES ('Kitchen',010000,4423)");

                myDatabase.ExecuteNonQuery(
                 "INSERT INTO Temperature (Room, Time,Value) " +
                 "VALUES ('living room',053000,9300)");

                myDatabase.ExecuteNonQuery(
                 "INSERT INTO Temperature (Room, Time,Value) " +
                 "VALUES ('bed room',060701,7200)");

                // Process SQL query and save returned records in SQLiteDataTable
                SQLiteDataTable table = myDatabase.ExecuteQuery("SELECT * FROM Temperature");

                // Get a copy of columns orign names example
                String[] origin_names = table.ColumnOriginNames;

                // Get a copy of table data example
                ArrayList[] tabledata = table.ColumnData;

                String temp = "Fields: ";
                for (int i = 0; i < table.Columns; i++)
                {
                    temp += table.ColumnOriginNames[i] + " |";
                }
                Debug.Print(temp);
                object obj;
                for (int j = 0; j < table.Rows; j++)
                {
                    temp = j.ToString() + " ";
                    for (int i = 0; i < table.Columns; i++)
                    {
                        obj = table.ReadRecord(i, j);
                        if (obj == null)
                            temp += "N/A";
                        else
                            temp += obj.ToString();
                        temp += " |";
                    }
                    Debug.Print(temp);

                }
                myDatabase.Close();
                //ps.UnmountFileSystem();
                //ps.Dispose();
            }
            catch (Exception e)
            {
                Debug.Print(e.Message);
                Debug.Print(Database.GetLastError());
            }
        }
开发者ID:KonstantinKolesnik,项目名称:Typhoon,代码行数:77,代码来源:Program.cs

示例6: Execute

 public override ResultSet Execute(Database database)
 {
     return database.ExecuteQuery(Columns);
 }
开发者ID:lgatto,项目名称:proteowizard,代码行数:4,代码来源:Report.cs


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