本文整理汇总了C#中Microsoft.Practices.EnterpriseLibrary.Data.Sql.SqlDatabase.ExecuteReader方法的典型用法代码示例。如果您正苦于以下问题:C# SqlDatabase.ExecuteReader方法的具体用法?C# SqlDatabase.ExecuteReader怎么用?C# SqlDatabase.ExecuteReader使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类Microsoft.Practices.EnterpriseLibrary.Data.Sql.SqlDatabase
的用法示例。
在下文中一共展示了SqlDatabase.ExecuteReader方法的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);
}
示例2: ToDataReader
public IDataReader ToDataReader(string storedProcedureName, Dictionary<string, string> parameters)
{
using (SqlCommand cmd = new SqlCommand(storedProcedureName))
{
cmd.CommandType = CommandType.StoredProcedure;
foreach (string key in parameters.Keys)
{
SqlParameter parameter = new SqlParameter(key, parameters[key]);
if (parameter.Value == null)
parameter.Value = DBNull.Value;
if (parameter.SqlDbType == SqlDbType.DateTime && parameter.Value is DateTime && (DateTime)parameter.Value == default(DateTime))
parameter.Value = SqlDateTime.MinValue.Value;
cmd.Parameters.Add(parameter);
}
SqlDatabase database = new SqlDatabase(ConfigurationManager.ConnectionStrings["MyAppsLocal"].ConnectionString);
try
{
IDataReader reader = database.ExecuteReader(cmd);
return reader;
}
catch (Exception e)
{
Console.WriteLine(e.ToString());
return null;
}
}
}
示例3: 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);
}
示例4: GetCustomer
public override CustomerList GetCustomer(string vipCode)
{
SqlDatabase database = new SqlDatabase(ConnectionString);
DbCommand command = database.GetStoredProcCommand("rmSP_WSPOS_GetCustomer");
command.CommandTimeout = 300;
database.AddInParameter(command, "@VipCode", DbType.String, vipCode);
List<Customer> customers = new List<Customer>();
using (IDataReader reader = database.ExecuteReader(command))
{
while (reader.Read())
{
Customer customer = new Customer();
customer.CustomerId = Convert.ToInt32(reader["VIPCode_id"]);
customer.CustomerCode = reader["VipCode"] as string;
customer.FirstName = reader["VIPGName"] as string;
customer.LastName = reader["VIPName"] as string;
customer.Telephone = reader["VIPTel"] as string;
if (reader["VIPBDay"] != DBNull.Value)
customer.BirthDate = Convert.ToDateTime(reader["VIPBDay"]);
customers.Add(customer);
}
}
CustomerList customerList = new CustomerList();
customerList.Customers = customers;
customerList.TotalCount = customers.Count;
return customerList;
}
示例5: 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;
}
示例6: 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);
}
示例7: lockedAccounts
public static IDataReader lockedAccounts()
{
SqlDatabase travelMSysDB = new SqlDatabase(ConnString.DBConnectionString);
SqlCommand queryCmmnd = new SqlCommand("SELECT * FROM EMPLOYEES WHERE Access_Status = 'F'");
queryCmmnd.CommandType = CommandType.Text;
return travelMSysDB.ExecuteReader(queryCmmnd);
}
示例8: JobsAssignedTo
public static IDataReader JobsAssignedTo(int clientId, int userId)
{
SqlDatabase db = new SqlDatabase(connString);
DbCommand command = db.GetStoredProcCommand("ALOC_JobsAssignedTo");
command.CommandType = CommandType.StoredProcedure;
db.AddInParameter(command, "@ClientId", DbType.Int32, clientId);
db.AddInParameter(command, "@UserId", DbType.Int32, userId);
return db.ExecuteReader(command);
}
示例9: Deparments
public static IDataReader Deparments(int clientId)
{
SqlDatabase db = new SqlDatabase( connString );
DbCommand command = db.GetStoredProcCommand( "ALOC__DepartmentSelectList" );
db.AddInParameter( command, "@ClientId", DbType.Int32, clientId );
command.CommandType = CommandType.StoredProcedure;
return db.ExecuteReader( command );
}
示例10: ViewClaimRequests
public static IDataReader ViewClaimRequests()
{
SqlDatabase travelMSysDB = new SqlDatabase(@"Data Source=(LocalDB)\v11.0;AttachDbFilename=|DataDirectory|\TravelMS_Sep16.mdf;Integrated Security=True");
SqlCommand reqListCmmnd = new SqlCommand("SELECT [Claim_ID],[Travel_Request_ID],[Claim_Amount],[Settled_Amount],[Emp_Remarks],[Admin_Remarks],[Claim_Status],[Admin_ID] FROM CLAIM_REQUESTS WHERE Travel_Request_ID IN (SELECT Travel_Request_ID FROM TRAVEL_REQUESTS WHERE Emp_ID = (SELECT Emp_ID FROM EMPLOYEES WHERE User_ID = @CurUser_ID))");
reqListCmmnd.Parameters.AddWithValue("@CurUser_ID", WebSecurity.CurrentUserName);
return travelMSysDB.ExecuteReader(reqListCmmnd);
}
示例11: populateTravelRequests
public static IDataReader populateTravelRequests(string currUserID)
{
SqlDatabase travelMSysDB = new SqlDatabase(ConnString.DBConnectionString);
SqlCommand queryCmmnd = new SqlCommand("SELECT Travel_Request_ID FROM TRAVEL_REQUESTS WHERE Emp_ID = (SELECT Emp_ID FROM EMPLOYEES WHERE User_ID = @User_ID)");
queryCmmnd.CommandType = CommandType.Text;
queryCmmnd.Parameters.AddWithValue("@User_ID", currUserID);
return travelMSysDB.ExecuteReader(queryCmmnd);
}
示例12: Clients
public static IDataReader Clients( string type, int userId )
{
SqlDatabase db = new SqlDatabase( connString );
DbCommand command = db.GetStoredProcCommand( "ALOC__ClientSelectList" );
command.CommandType = CommandType.StoredProcedure;
db.AddInParameter( command, "@Type", DbType.String, type );
db.AddInParameter( command, "@UserId", DbType.Int32, userId );
return db.ExecuteReader( command );
}
示例13: 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);
}
示例14: SelectUser
private static bool SelectUser(ref User user)
{
try
{
SqlDatabase db = new SqlDatabase(Properties.Settings.Default.connString);
using (DbCommand cmd = db.GetStoredProcCommand("SelectUser"))
{
db.AddInParameter(cmd, "authcode", DbType.String, user.AuthCode);
using (IDataReader dr = db.ExecuteReader(cmd))
{
bool first = true;
while (dr.Read())
{
if (first)
{
user.Age = dr["age"] as string;
user.AuthCode = dr["authcode"] as string;
user.Gender = dr["gender"] as string;
first = false;
}
int? tid = dr["testid"] as int?;
if (tid != null)
{
Test t = null;
if (user.Tests.ContainsKey(tid.Value))
t = user.Tests[tid.Value];
else
{
t = new Test()
{
ID = tid.Value,
TimeEst = (int)dr["timeest"],
MaxArraySize = (int)dr["maxarraysize"],
DelayPeriod = (int)dr["delayperiod"]
};
user.Tests.Add(tid.Value, t);
}
t.ImageArrays.Add(new ImageArray()
{
Index = (int)dr["index"],
ImagesDisplayed = (int)dr["imagesdisplayed"],
UserInput = (int)dr["userinput"],
ImageFile = (string)dr["imagefile"]
});
}
}
}
return true;
}
}
catch
{
return false;
}
}
示例15: User_IDCheckDAL
public static IDataReader User_IDCheckDAL(string requestedUser_ID)
{
SqlDatabase travelMSysDB = new SqlDatabase(ConnString.DBConnectionString);
SqlCommand queryCmmnd = new SqlCommand("SELECT User_ID FROM EMPLOYEES WHERE [email protected]_ID");
queryCmmnd.CommandType = CommandType.Text;
queryCmmnd.Parameters.AddWithValue("@User_ID", requestedUser_ID);
return travelMSysDB.ExecuteReader(queryCmmnd);
}