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


C# DataBaseConnection.SqlConn方法代码示例

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


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

示例1: GetFields

        public Fields GetFields(int FieldsId)
        {
            Fields ins = new Fields();

            //...Database Connection...
            DataBaseConnection dbConn = new DataBaseConnection();
            SqlConnection con = dbConn.SqlConn();
            SqlCommand cmdI;

            //...SQL Commands...
            cmdI = new SqlCommand("SELECT * FROM Fields WHERE FieldsId =" + FieldsId, con);
            cmdI.Connection.Open();
            SqlDataReader drI = cmdI.ExecuteReader();

            //...Retrieve Data...
            if (drI.HasRows)
            {
                while (drI.Read())
                {
                    ins.FieldsId = Convert.ToInt32(drI["FieldsId"]);
                    ins.ClientId = Convert.ToInt32(drI["ClientId"]);
                    ins.FieldName = drI["FieldName"].ToString();
                    ins.SportCategoryID = Convert.ToInt32(drI["SportCategoryID"]);

                }
            }
            drI.Close();
            con.Close();

            return ins;
        }
开发者ID:Ricium,项目名称:NIWZ_101,代码行数:31,代码来源:FieldRepository.cs

示例2: GetSchoolList

        public List<SelectListItem> GetSchoolList()
        {
            List<SelectListItem> list = new List<SelectListItem>();
            SelectListItem ins;

            //...Database Connection...
            DataBaseConnection dbConn = new DataBaseConnection();
            SqlConnection con = dbConn.SqlConn();
            SqlCommand cmdI;

            //...SQL Commands...
            cmdI = new SqlCommand("SELECT * FROM Client", con);
            cmdI.Connection.Open();
            SqlDataReader drI = cmdI.ExecuteReader();

            //...Retrieve Data...
            if (drI.HasRows)
            {
                while (drI.Read())
                {
                    ins = new SelectListItem();
                    ins.Value = drI["ClientId"].ToString();
                    ins.Text = drI["Name"].ToString();
                    list.Add(ins);
                }
            }
            drI.Close();
            con.Close();

            return list;
        }
开发者ID:Ricium,项目名称:NIWZ_101,代码行数:31,代码来源:SchoolInfoRepository.cs

示例3: GetLastPictureId

        public int GetLastPictureId(int ClientId)
        {
            int returnValue = 0;

            //...Database Connection...
            DataBaseConnection dbConn = new DataBaseConnection();
            SqlConnection con = dbConn.SqlConn();
            SqlCommand cmdI;

            //...SQL Commands...
            cmdI = new SqlCommand("SELECT TOP 1 PictureId FROM Picture WHERE ClientId=" + ClientId + " ORDER BY PictureId DESC", con);
            cmdI.Connection.Open();
            SqlDataReader drI = cmdI.ExecuteReader();

            //...Retrieve Data...
            if (drI.HasRows)
            {
                while (drI.Read())
                {
                    returnValue = Convert.ToInt32(drI["PictureId"]);
                }
            }
            drI.Close();
            con.Close();

            return returnValue;
        }
开发者ID:Ricium,项目名称:NIWZ_101,代码行数:27,代码来源:PictureRepository.cs

示例4: GetNews

        public int GetNews(int ClientId)
        {
            int returnValue = 0;

            //...Database Connection...
            DataBaseConnection dbConn = new DataBaseConnection();
            SqlConnection con = dbConn.SqlConn();
            SqlCommand cmdI;

            //...SQL Commands...
            cmdI = new SqlCommand("SELECT COUNT(ClientId) as NumberOfUsers FROM News WHERE ClientId =" + ClientId, con);
            cmdI.Connection.Open();
            SqlDataReader drI = cmdI.ExecuteReader();

            //...Retrieve Data...
            if (drI.HasRows)
            {
                while (drI.Read())
                {
                    returnValue = Convert.ToInt32(drI["NumberOfUsers"]);
                }
            }

            //...Clean Up...
            drI.Close();
            con.Close();

            //...Return...
            return returnValue;
        }
开发者ID:Ricium,项目名称:NIWZ_101,代码行数:30,代码来源:StatsRepository.cs

示例5: GetClient

        public Client GetClient(int ClientId)
        {
            Client ins = new Client();

            //...Database Connection...
            DataBaseConnection dbConn = new DataBaseConnection();
            SqlConnection con = dbConn.SqlConn();
            SqlCommand cmdI;

            //...SQL Commands...
            cmdI = new SqlCommand("SELECT * FROM Client WHERE ClientId =" + ClientId, con);
            cmdI.Connection.Open();
            SqlDataReader drI = cmdI.ExecuteReader();

            //...Retrieve Data...
            if (drI.HasRows)
            {
                while (drI.Read())
                {
                    ins.ClientId = Convert.ToInt32(drI["ClientId"]);
                    ins.Name = drI["Name"].ToString();
                }
            }
            drI.Close();
            con.Close();

            return ins;
        }
开发者ID:Ricium,项目名称:NIWZ_101,代码行数:28,代码来源:SchoolInfoRepository.cs

示例6: GetFacebookToken

        public string GetFacebookToken(int ClientId)
        {
            string returnValue = "";

            //...Database Connection...
            DataBaseConnection dbConn = new DataBaseConnection();
            SqlConnection con = dbConn.SqlConn();
            SqlCommand cmdI;

            //...SQL Commands...
            cmdI = new SqlCommand("SELECT * FROM Settings WHERE ClientId = " + ClientId + " AND Setting = 'facebook'", con);
            cmdI.Connection.Open();
            SqlDataReader drI = cmdI.ExecuteReader();

            //...Retrieve Data...
            if (drI.HasRows)
            {
                while (drI.Read())
                {
                    returnValue = drI["Value"].ToString();
                }
            }

            drI.Close();
            con.Close();

            return returnValue;
        }
开发者ID:Ricium,项目名称:NIWZ_101,代码行数:28,代码来源:SettingRepository.cs

示例7: GetListSportCategoryportCategorys

        public List<SportCategory> GetListSportCategoryportCategorys()
        {
            List<SportCategory> list = new List<SportCategory>();
            SportCategory ins;

            //...Database Connection...
            DataBaseConnection dbConn = new DataBaseConnection();
            SqlConnection con = dbConn.SqlConn();
            SqlCommand cmdI;

            //...SQL Commands...
            cmdI = new SqlCommand("SELECT * from SportCategory", con);
            cmdI.Connection.Open();
            SqlDataReader drI = cmdI.ExecuteReader();

            //...Retrieve Data...
            if (drI.HasRows)
            {
                while (drI.Read())
                {
                    ins = new SportCategory();
                    ins.SportCategoryID = Convert.ToInt32(drI["SportCategoryId"]);
                    ins.ClientID = Convert.ToInt32(drI["ClientId"]);
                    ins.CategoryName = drI["CategoryName"].ToString();
                    list.Add(ins);
                }
            }
            drI.Close();
            con.Close();

            return list;
        }
开发者ID:Ricium,项目名称:NIWZ_101,代码行数:32,代码来源:SportCategoryRepository.cs

示例8: GetAllUsernames

        public List<string> GetAllUsernames()
        {
            List<string> usernames = new List<string>();

            DataBaseConnection dbConn = new DataBaseConnection();
            SqlConnection con = dbConn.SqlConn();
            SqlCommand cmdI = con.CreateCommand();
            cmdI.Connection = con;

            cmdI.Parameters.Clear();
            cmdI.CommandText = CommonStrings.GetAllUsers;
            cmdI.CommandType = System.Data.CommandType.StoredProcedure;
            cmdI.Connection.Open();

            SqlDataReader drI = cmdI.ExecuteReader();

            if (drI.HasRows)
            {
                while (drI.Read())
                {
                    usernames.Add(drI["Username"].ToString());
                }
            }

            cmdI.Connection.Close();
            con.Dispose();

            return usernames;
        }
开发者ID:Ricium,项目名称:Wetu,代码行数:29,代码来源:CommonRepository.cs

示例9: GetFixtures

        public List<SelectListItem> GetFixtures(int? sc)
        {
            List<SelectListItem> obj = new List<SelectListItem>();

            DataBaseConnection dbConn = new DataBaseConnection();
            SqlConnection con = dbConn.SqlConn();
            SqlCommand cmdI = new SqlCommand("select f.*,s.Schoolabbreviation as teamA,sb.Schoolabbreviation as teamB,t.Age as AgeA,tb.Age as AgeB,t.Ranks as RankA,tb.Ranks as RankB from fixtures f inner join Teams t on f.TeamIdA = t.TeamsId inner join Teams tb on f.TeamIdB=tb.TeamsId inner join Schools s on t.SchoolId = s.SchoolId inner join Schools sb on tb.SchoolId = sb.SchoolId where f.SportCategoryID ='"+sc+"'and f.FixturesId not in (select FixtureId from Results) ", con);
            cmdI.Connection.Open();
            SqlDataReader drI = cmdI.ExecuteReader();

            if (drI.HasRows)
            {
                while (drI.Read())
                {
                    var result = new SelectListItem();
                    result.Text = drI["teamA"].ToString() + " " + drI["AgeA"].ToString() + "/" + drI["RankA"].ToString() + " VS " + drI["teamB"].ToString() + " " + drI["AgeB"].ToString() + "/" + drI["RankB"].ToString() + " " + drI["StartTime"].ToString();
                    result.Value = drI["FixturesId"].ToString();
                    obj.Add(result);
                }
            }
            drI.Close();
            con.Close();
            con.Dispose();

            return obj;
        }
开发者ID:Ricium,项目名称:NIWZ_101,代码行数:26,代码来源:ResultsRepository.cs

示例10: GetAnimals

        public List<AnimalSim> GetAnimals(int CompanyId, int SexId)
        {
            List<AnimalSim> ReturnObject = new List<AnimalSim>();
            AnimalSim ins;

            DataBaseConnection dbConn = new DataBaseConnection();

                using (var con = dbConn.SqlConn())
                {
                    con.Open();

                    using (SqlCommand cmd = new SqlCommand("exec " + CommonStrings.SimAnimals + " @CompanyId, @SexId", con))
                    {
                        cmd.Parameters.AddWithValue("@CompanyId", CompanyId);
                        cmd.Parameters.AddWithValue("@SexId", SexId);

                        using (var drI = cmd.ExecuteReader())
                        {
                            while (drI.Read())
                            {
                                ins = new AnimalSim();
                                ins.AnimalId = Convert.ToInt32(drI["AnimalId"]);
                                ins.DeviceAddress = drI["DeviceAddress"].ToString();
                                ReturnObject.Add(ins);
                            }
                        }
                    }

            }

            return ReturnObject;
        }
开发者ID:Ricium,项目名称:Wetu,代码行数:32,代码来源:SimulateRepository.cs

示例11: GetPublicRegistrar

        public List<int> GetPublicRegistrar()
        {
            List<int> ReturnObject = new List<int>();

            DataBaseConnection dbConn = new DataBaseConnection();

            using (var con = dbConn.SqlConn())
            {
                con.Open();

                using (SqlCommand cmd = new SqlCommand("exec " + CommonStrings.GetPublicRegistrar, con))
                {

                    using (var drI = cmd.ExecuteReader())
                    {
                        while (drI.Read())
                        {
                            ReturnObject.Add(Convert.ToInt32(drI["AnimalId"]));
                        }
                    }
                }

            }

            return ReturnObject;
        }
开发者ID:Ricium,项目名称:Wetu,代码行数:26,代码来源:SimulateRepository.cs

示例12: GetListSchools

        public List<Schoolsc> GetListSchools()
        {
            List<Schoolsc> list = new List<Schoolsc>();
            Schoolsc ins;

            //...Database Connection...
            DataBaseConnection dbConn = new DataBaseConnection();
            SqlConnection con = dbConn.SqlConn();
            SqlCommand cmdI;

            //...SQL Commands...
            cmdI = new SqlCommand("SELECT * FROM Schools ", con);
            cmdI.Connection.Open();
            SqlDataReader drI = cmdI.ExecuteReader();

            //...Retrieve Data...
            if (drI.HasRows)
            {
                while (drI.Read())
                {
                    ins = new Schoolsc();
                    ins.SchoolId = Convert.ToInt32(drI["SchoolId"]);
                    ins.ClientId = Convert.ToInt32(drI["ClientId"]);
                    ins.SchoolName = drI["SchoolName"].ToString();
                    ins.Schoolabbreviation = drI["Schoolabbreviation"].ToString();
                    ins.PictureId = Convert.ToInt32(drI["PictureId"]);
                    list.Add(ins);
                }
            }
            drI.Close();
            con.Close();

            return list;
        }
开发者ID:Ricium,项目名称:NIWZ_101,代码行数:34,代码来源:SchoolsRepository.cs

示例13: GetListFields

        public List<Fields> GetListFields()
        {
            List<Fields> list = new List<Fields>();
            Fields ins;

            //...Database Connection...
            DataBaseConnection dbConn = new DataBaseConnection();
            SqlConnection con = dbConn.SqlConn();
            SqlCommand cmdI;

            //...SQL Commands...
            cmdI = new SqlCommand("SELECT f.*,sc.CategoryName FROM Fields f inner join SportCategory sc on f.SportCategoryID =sc.SportCategoryID", con);
            cmdI.Connection.Open();
            SqlDataReader drI = cmdI.ExecuteReader();

            //...Retrieve Data...
            if (drI.HasRows)
            {
                while (drI.Read())
                {
                    ins = new Fields();
                    ins.FieldsId = Convert.ToInt32(drI["FieldsId"]);
                    ins.ClientId = Convert.ToInt32(drI["ClientId"]);
                    ins.SportCategoryID = Convert.ToInt32(drI["SportCategoryID"]);
                    ins.FieldName = drI["FieldName"].ToString();
                    ins.sportcategory = drI["CategoryName"].ToString();

                    list.Add(ins);
                }
            }
            drI.Close();
            con.Close();

            return list;
        }
开发者ID:Ricium,项目名称:NIWZ_101,代码行数:35,代码来源:FieldRepository.cs

示例14: GetFieldsPerSC

        public List<SelectListItem> GetFieldsPerSC(int? SportCategory)
        {
            List<SelectListItem> obj = new List<SelectListItem>();

            DataBaseConnection dbConn = new DataBaseConnection();
            SqlConnection con = dbConn.SqlConn();
            SqlCommand cmdI = new SqlCommand("SELECT f.*,sc.CategoryName FROM Fields f inner join SportCategory sc on f.SportCategoryID =sc.SportCategoryId where f.SportCategoryID ='" + SportCategory+"'", con);
            cmdI.Connection.Open();
            SqlDataReader drI = cmdI.ExecuteReader();

            if (drI.HasRows)
            {
                while (drI.Read())
                {
                    var result = new SelectListItem();
                    result.Text = drI["FieldName"].ToString();
                    result.Value = drI["FieldsId"].ToString();
                    obj.Add(result);
                }
            }
            drI.Close();
            con.Close();
            con.Dispose();

            return obj;
        }
开发者ID:Ricium,项目名称:NIWZ_101,代码行数:26,代码来源:FieldRepository.cs

示例15: GetListRegisterClient

        public List<RegisterClient> GetListRegisterClient(int ClientId)
        {
            List<RegisterClient> list = new List<RegisterClient>();
            RegisterClient ins;

            //...Database Connection...
            DataBaseConnection dbConn = new DataBaseConnection();
            SqlConnection con = dbConn.SqlConn();
            SqlCommand cmdI;

            //...SQL Commands...
            cmdI = new SqlCommand("SELECT * FROM RegisterClient WHERE ClientId = " + ClientId + " ORDER BY RegisterClientId DESC", con);
            cmdI.Connection.Open();
            SqlDataReader drI = cmdI.ExecuteReader();

            //...Retrieve Data...
            if (drI.HasRows)
            {
                while (drI.Read())
                {
                    ins = new RegisterClient();
                    ins.RegisterClientID = Convert.ToInt32(drI["RegisterClientId"]);
                    ins.ClientId = Convert.ToInt32(drI["ClientId"]);
                    ins.ClientNo = drI["TeamIdA"].ToString();
                    ins.Email = drI["TeamIdB"].ToString();
                    ins.Passwords = drI["StartTime"].ToString();
                    ins.Approved = Convert.ToBoolean(drI["Approved"]);
                    list.Add(ins);
                }
            }
            drI.Close();
            con.Close();

            return list;
        }
开发者ID:Ricium,项目名称:NIWZ_101,代码行数:35,代码来源:GateRepository.cs


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