本文整理汇总了C#中Mono.Data.Sqlite.SqliteCommand.Cancel方法的典型用法代码示例。如果您正苦于以下问题:C# SqliteCommand.Cancel方法的具体用法?C# SqliteCommand.Cancel怎么用?C# SqliteCommand.Cancel使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类Mono.Data.Sqlite.SqliteCommand
的用法示例。
在下文中一共展示了SqliteCommand.Cancel方法的2个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C#代码示例。
示例1: GetAllUsers
//
// MembershipProvider.GetAllUsers
//
public override MembershipUserCollection GetAllUsers(int pageIndex, int pageSize, out int totalRecords)
{
SqliteConnection conn = new SqliteConnection(connectionString);
SqliteCommand cmd = new SqliteCommand("SELECT Count(*) FROM `" + tableName + "` " +
"WHERE ApplicationName = $ApplicationName", conn);
cmd.Parameters.Add("$ApplicationName", DbType.String, 255).Value = ApplicationName;
MembershipUserCollection users = new MembershipUserCollection();
SqliteDataReader reader = null;
totalRecords = 0;
try
{
conn.Open();
totalRecords = Convert.ToInt32(cmd.ExecuteScalar());
if (totalRecords <= 0) { return users; }
cmd.CommandText = "SELECT PKID, Username, Email, PasswordQuestion," +
" Comment, IsApproved, IsLockedOut, CreationDate, LastLoginDate," +
" LastActivityDate, LastPasswordChangedDate, LastLockedOutDate " +
" FROM `" + tableName + "` " +
" WHERE ApplicationName = $ApplicationName " +
" ORDER BY Username Asc";
reader = cmd.ExecuteReader();
int counter = 0;
int startIndex = pageSize * pageIndex;
int endIndex = startIndex + pageSize - 1;
while (reader.Read())
{
if (counter >= startIndex)
{
MembershipUser u = GetUserFromReader(reader);
users.Add(u);
}
if (counter >= endIndex) { cmd.Cancel(); }
counter++;
}
}
catch (SqliteException e)
{
if (WriteExceptionsToEventLog)
{
WriteToEventLog(e, "GetAllUsers");
throw new ProviderException(exceptionMessage);
}
else
{
throw e;
}
}
finally
{
if (reader != null) { reader.Close(); }
conn.Close();
}
return users;
}
示例2: FindUsersByName
public override MembershipUserCollection FindUsersByName(
string usernameToMatch, int pageIndex, int pageSize,
out int totalRecords)
{
SqliteConnection conn = new SqliteConnection(connectionString);
SqliteCommand cmd = new SqliteCommand("SELECT Count(*) FROM `" + tableName + "` " +
"WHERE Username LIKE $UsernameSearch AND ApplicationName = $ApplicationName", conn);
cmd.Parameters.Add("$UsernameSearch", DbType.String).Value = usernameToMatch;
cmd.Parameters.Add("$ApplicationName", DbType.String).Value = pApplicationName;
MembershipUserCollection users = new MembershipUserCollection();
SqliteDataReader reader = null;
totalRecords = 0;
try
{
conn.Open();
totalRecords = Convert.ToInt32(cmd.ExecuteScalar());
if (totalRecords <= 0) { return users; }
cmd.CommandText = "SELECT PKID, Username, Email, PasswordQuestion," +
" Comment, IsApproved, IsLockedOut, CreationDate, LastLoginDate," +
" LastActivityDate, LastPasswordChangedDate, LastLockedOutDate " +
" FROM `" + tableName + "` " +
" WHERE Username LIKE $UsernameSearch AND ApplicationName = $ApplicationName " +
" ORDER BY Username Asc";
reader = cmd.ExecuteReader();
int counter = 0;
int startIndex = pageSize * pageIndex;
int endIndex = startIndex + pageSize - 1;
while (reader.Read())
{
if (counter >= startIndex)
{
MembershipUser u = GetUserFromReader(reader);
users.Add(u);
}
if (counter >= endIndex) { cmd.Cancel(); }
counter++;
}
}
catch (Exception e)
{
log.Error(e.Message, e.InnerException);
}
finally
{
if (reader != null) { reader.Close(); }
conn.Close();
}
return users;
}