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


C# SqlDatabase.GetSqlStringCommand方法代码示例

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


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

示例1: Departments

 public static IDataReader Departments()
 {
     SqlDatabase db = new SqlDatabase(connString);
     DbCommand command = db.GetSqlStringCommand("SELECT DeptId, Name FROM AllDepartments D WHERE D.Active=1 AND D.NormBillsTime=1 ORDER BY Name");
     command.CommandType = CommandType.Text;
     return db.ExecuteReader(command);
 }
开发者ID:the0ther,项目名称:how2www.info,代码行数:7,代码来源:Department.cs

示例2: GetIDataReader

 public static IDataReader GetIDataReader(string connectionString, string sqlQuery)
 {
     SqlDatabase sqlServerDB = new SqlDatabase(connectionString);
     DbCommand cmd = sqlServerDB.GetSqlStringCommand(sqlQuery);
     //return an IDataReader.
     return sqlServerDB.ExecuteReader(cmd);
 }
开发者ID:namanbansal,项目名称:NotificationProcessor,代码行数:7,代码来源:WebhookNotificationBAL.cs

示例3: GetResources

        public static DataTable GetResources(int jobId, int deptId)
        {
            SqlDatabase db = new SqlDatabase(connString);
            string sql = @" SELECT	U.UserId, U.FirstName + ' ' + U.LastName AS FullName, 
		                            t.TitleName as Title
                            FROM	AllocableUsers U LEFT JOIN JobTitles AS t ON U.currentTitleID=t.TitleID
                            WHERE	U.Active=1 AND U.UserId NOT IN (
                                    SELECT UserId FROM Assignments WHERE [email protected]_id
                                    AND (EndDate IS NULL OR EndDate>DATEADD(s, 1, CURRENT_TIMESTAMP))) 
                                    AND [email protected]_id AND realPerson='Y'
		                            AND UserId NOT IN (
			                            SELECT	UserId
			                            FROM	timeEntry
			                            WHERE	[email protected]_id AND UserId=U.UserId AND (TimeSpan IS NULL OR TimeSpan > 0)
		                            )
                            ORDER BY FullName";

            DbCommand command = db.GetSqlStringCommand(sql);
            db.AddInParameter(command, "@job_id", DbType.Int32, jobId);
            db.AddInParameter(command, "@dept_id", DbType.Int32, deptId);
            DataTable t = new DataTable();
            t = db.ExecuteDataSet(command).Tables[0].Copy();
            t.TableName = "Resources";
            command.Dispose();
            return t;
        }
开发者ID:the0ther,项目名称:how2www.info,代码行数:26,代码来源:ManageAssignments.cs

示例4: Authenticate

            public static UserAuthResult Authenticate(string userName, string password, string providerKey)
            {
                string Auth_GetUserByCredentials =
                @"SELECT u.ID,u.Name,u.Surname,u.Email,u.Password,u.About,u.BirthDate,u.DateCreated,u.LastLogin,u.DateUpdated,ul.LoginProvider 
                FROM User AS u
                INNER JOIN UserLogin AS ul 
                ON u.ID = ul.UserID
                WHERE  u.Email = '{1}'

                WHERE  ul.Providerkey = '{1}'";

                string connStr = ConfigurationManager.AppSettings["MasterSQLConnection"];
                SqlDatabase db = new SqlDatabase(connStr);
                UserAuthResult result = new UserAuthResult();
                result.AuthSuccess = false;
                User user = new User();
                string dbPassword = string.Empty;
                try
                {
                    string query = String.Format(Auth_GetUserByCredentials, userName);
                    using (DbCommand command = db.GetSqlStringCommand(query))
                    {

                        using (IDataReader reader = db.ExecuteReader(command))
                        {
                            if (reader.Read())
                            {
                                //Users.ID,Users.Name,Surname,IsAdmin,IsSuperAdmin,LoginType,Users.ActiveDirectoryDomain,Password
                                user.ID       = int.Parse(reader["ID"].ToString());
                                user.Password = reader["Password"].ToString();
                                user.Name     = reader["Name"].ToString();
                                user.Surname  = reader["Surname"].ToString();
                            }
                            else
                            {
                                result.AuthSuccess = false;
                                result.ErrorMsg = "Username or password is wrong";
                            }
                        }
                    }
                }
                finally
                {
                }


                if (!string.IsNullOrEmpty(password) && user.ID > 0 && password.Equals(user.Password))
                {
                    result.User = user;
                    result.AuthSuccess = true;
                }
                else
                {
                    result.ErrorMsg = "Username or password is wrong";
                }

                return result;

            }
开发者ID:cicimen,项目名称:normalmi,代码行数:59,代码来源:User.cs

示例5: Employees

        public static IDataReader Employees(int deptId)
        {
            SqlDatabase db = new SqlDatabase(connString);
            DbCommand command = db.GetSqlStringCommand("SELECT FirstName + ' ' + LastName AS FullName, UserId FROM AllocableUsers WHERE DeptId=" + deptId + " AND Active=1 ORDER BY FullName");
            command.CommandType = CommandType.Text;

            return db.ExecuteReader(command);
        }
开发者ID:the0ther,项目名称:how2www.info,代码行数:8,代码来源:Employee.cs

示例6: UpdateRole

        public static void UpdateRole(Role role)
        {
            string sqlQuery = "UPDATE ROLE SET [email protected] WHERE RoleID=" + role.RoleID;

            Database db = new SqlDatabase(DBHelper.GetConnectionString());
            DbCommand dbCommand = db.GetSqlStringCommand(sqlQuery);
            db.AddInParameter(dbCommand, "Name", DbType.String, role.Name);
            db.ExecuteNonQuery(dbCommand);
        }
开发者ID:tsubik,项目名称:SFASystem,代码行数:9,代码来源:RoleDB.cs

示例7: WriteToDb

        //To write to DB
        public static int WriteToDb(string connectionString, string sqlQuery)
        {
            SqlDatabase db = new SqlDatabase(connectionString);

            DbCommand cmd = db.GetSqlStringCommand(sqlQuery);

            //return the number of rows affected
            return db.ExecuteNonQuery(cmd);
        }
开发者ID:namanbansal,项目名称:NotificationProcessor,代码行数:10,代码来源:WebhookNotificationBAL.cs

示例8: AddEmployeeToRole

        public static void AddEmployeeToRole(int employeeID, int roleID)
        {
            string sqlQuery = "INSERT INTO EMPLOYEEROLES(EmployeeID, RoleID) Values (@EmployeeID, @RoleID)";
            Database db = new SqlDatabase(DBHelper.GetConnectionString());
            DbCommand dbCommand = db.GetSqlStringCommand(sqlQuery);
            db.AddInParameter(dbCommand, "EmployeeID", DbType.Int32, employeeID);
            db.AddInParameter(dbCommand, "RoleID", DbType.Int32, roleID);

            db.ExecuteNonQuery(dbCommand);
        }
开发者ID:tsubik,项目名称:SFASystem,代码行数:10,代码来源:EmployeeDB.cs

示例9: GetJobEndDate

 public static DateTime GetJobEndDate(int jobId)
 {
     SqlDatabase db = new SqlDatabase(connString);
     DbCommand command = db.GetSqlStringCommand("SELECT currentEndDate FROM AllOpenJobs WHERE JobId=" + jobId);
     DateTime retval = DateTime.MinValue;
     object obj = db.ExecuteScalar(command);
     if (obj != DBNull.Value)
         retval = Convert.ToDateTime(obj);
     return retval;
 }
开发者ID:the0ther,项目名称:how2www.info,代码行数:10,代码来源:Utility.cs

示例10: AllJobs

 public static IDataReader AllJobs(int clientId)
 {
     SqlDatabase db = new SqlDatabase(connString);
     DbCommand command = db.GetSqlStringCommand(@"
         SELECT  JobId, Name FROM AllOpenJobs J  
         WHERE   Active=1 AND [email protected]
         ORDER BY Name");
     db.AddInParameter(command, "@clientId", DbType.Int32, clientId);
     return db.ExecuteReader(command);
 }
开发者ID:the0ther,项目名称:how2www.info,代码行数:10,代码来源:Job.cs

示例11: UpdateCity

        public static void UpdateCity(City city)
        {
            string sqlQuery = "UPDATE City SET [email protected] WHERE CityID=" + city.CityID;

            Database db = new SqlDatabase(DBHelper.GetConnectionString());
            DbCommand dbCommand = db.GetSqlStringCommand(sqlQuery);
            db.AddInParameter(dbCommand, "Name", DbType.String, city);

            db.ExecuteNonQuery(dbCommand);
        }
开发者ID:tsubik,项目名称:SFASystem,代码行数:10,代码来源:CityDB.cs

示例12: DeleteEmployee

 public static bool DeleteEmployee(int employeeID)
 {
     string sqlQuery = "UPDATE EMPLOYEE SET Active=0 WHERE EmployeeID = " + employeeID.ToString();
     Database db = new SqlDatabase(DBHelper.GetConnectionString());
     DbCommand dbCommand = db.GetSqlStringCommand(sqlQuery);
     if (db.ExecuteNonQuery(dbCommand) > 0)
         return true;
     else
         return false;
 }
开发者ID:tsubik,项目名称:SFASystem,代码行数:10,代码来源:EmployeeDB.cs

示例13: TestInitialize

		public void TestInitialize()
        {
            string partitionName = "Partition1";

            backingStore = CreateBackingStore(instanceName, partitionName);

			Data.Database db = new SqlDatabase(@"server=(local)\SQLEXPRESS;database=Caching;Integrated Security=true");
            DbCommand wrapper = db.GetSqlStringCommand("delete from CacheData");
            db.ExecuteNonQuery(wrapper);
        }
开发者ID:ChiangHanLung,项目名称:PIC_VDS,代码行数:10,代码来源:DataBackingStoreFixture.cs

示例14: GetDeptIdForUser

 public static int GetDeptIdForUser(int userId)
 {
     int retval = -1;
     SqlDatabase db = new SqlDatabase(connString);
     DbCommand command = db.GetSqlStringCommand("SELECT DeptId FROM AllocableUsers WHERE UserId=" + userId);
     command.CommandType = CommandType.Text;
     object obj = db.ExecuteScalar(command);
     if (obj != DBNull.Value)
         retval = Convert.ToInt32(obj);
     return retval;
 }
开发者ID:the0ther,项目名称:how2www.info,代码行数:11,代码来源:Utility.cs

示例15: GetClientIdForJob

 public static int GetClientIdForJob(int jobId)
 {
     int retval = -1;
     SqlDatabase db = new SqlDatabase(connString);
     DbCommand command = db.GetSqlStringCommand("SELECT ClientId FROM AllOpenJobs WHERE JobId=" + jobId);
     command.CommandType = CommandType.Text;
     object obj = db.ExecuteScalar(command);
     if (obj != DBNull.Value)
         retval = Convert.ToInt32(obj);
     return retval;
 }
开发者ID:the0ther,项目名称:how2www.info,代码行数:11,代码来源:Utility.cs


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