本文整理汇总了C#中VzfSqlCommand.ExecuteScalar方法的典型用法代码示例。如果您正苦于以下问题:C# VzfSqlCommand.ExecuteScalar方法的具体用法?C# VzfSqlCommand.ExecuteScalar怎么用?C# VzfSqlCommand.ExecuteScalar使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类VzfSqlCommand
的用法示例。
在下文中一共展示了VzfSqlCommand.ExecuteScalar方法的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C#代码示例。
示例1: accessmask_delete
/// <summary>
/// Deletes the access mask.
/// </summary>
/// <param name="mid">
/// The module id.
/// </param>
/// <param name="accessMaskId">
/// The access mask id.
/// </param>
/// <returns>
/// A <see cref="T:System.Boolean"/> with true if access mask was deleted and false if deletion failed.
/// </returns>
public static bool accessmask_delete(int? mid, object accessMaskId)
{
using (var sc = new VzfSqlCommand(mid))
{
sc.Parameters.Add(sc.CreateParameter(DbType.Int32, "i_AccessMaskID", accessMaskId));
sc.CommandText.AppendObjectQuery("accessmask_delete", mid);
return Convert.ToBoolean(sc.ExecuteScalar(CommandType.StoredProcedure));
}
}
示例2: board_create
/// <summary>
/// The board_create.
/// </summary>
/// <param name="mid">
/// The mid.
/// </param>
/// <param name="adminUsername">
/// The admin username.
/// </param>
/// <param name="adminUserEmail">
/// The admin user email.
/// </param>
/// <param name="adminUserKey">
/// The admin user key.
/// </param>
/// <param name="boardName">
/// The board name.
/// </param>
/// <param name="culture">
/// The culture.
/// </param>
/// <param name="languageFile">
/// The language file.
/// </param>
/// <param name="boardMembershipName">
/// The board membership name.
/// </param>
/// <param name="boardRolesName">
/// The board roles name.
/// </param>
/// <param name="rolePrefix">
/// The role prefix.
/// </param>
/// <param name="isHostUser">
/// The is host user.
/// </param>
/// <returns>
/// The <see cref="int"/> id of a new board.
/// </returns>
public static int board_create(
int? mid,
object adminUsername,
object adminUserEmail,
object adminUserKey,
object boardName,
object culture,
object languageFile,
object boardMembershipName,
object boardRolesName,
object rolePrefix,
object isHostUser)
{
using (var sc = new VzfSqlCommand(mid))
{
sc.Parameters.Add(sc.CreateParameter(DbType.String, "i_BoardName", boardName));
sc.Parameters.Add(sc.CreateParameter(DbType.String, "i_Culture", culture));
sc.Parameters.Add(sc.CreateParameter(DbType.String, "i_LanguageFile", languageFile));
sc.Parameters.Add(sc.CreateParameter(DbType.String, "i_MembershipAppName", boardMembershipName));
sc.Parameters.Add(sc.CreateParameter(DbType.String, "i_RolesAppName", boardRolesName));
sc.Parameters.Add(sc.CreateParameter(DbType.String, "i_UserName", adminUsername));
sc.Parameters.Add(sc.CreateParameter(DbType.String, "i_UserEmail", adminUserEmail));
sc.Parameters.Add(sc.CreateParameter(DbType.String, "i_UserKey", adminUserKey));
sc.Parameters.Add(sc.CreateParameter(DbType.Boolean, "i_IsHostAdmin", isHostUser));
sc.Parameters.Add(sc.CreateParameter(DbType.String, "i_RolePrefix", rolePrefix));
sc.Parameters.Add(sc.CreateParameter(DbType.DateTime, "i_UTCTIMESTAMP", DateTime.UtcNow));
sc.CommandText.AppendObjectQuery("board_create", mid);
return Convert.ToInt32(sc.ExecuteScalar(CommandType.StoredProcedure));
}
}
示例3: GetApplicationIdFromName
private static object GetApplicationIdFromName(string connectionStringName, string appName)
{
using (var sc = new VzfSqlCommand(connectionStringName))
{
sc.Parameters.Add(sc.CreateParameter(DbType.String, "i_applicationname", appName));
sc.Parameters.Add(sc.CreateParameter(DbType.Guid, "i_newguid", Guid.NewGuid()));
sc.Parameters.Add(sc.CreateParameter(DbType.Guid, "i_applicationid", null, ParameterDirection.Output));
// cmd.Parameters.Add(new FbParameter("@I_USERID", FbDbType.VarChar)).Value = userID;
sc.CommandText.AppendObjectQuery("prov_createapplication", connectionStringName);
return sc.ExecuteScalar(CommandType.StoredProcedure, false);
}
}
示例4: __GetNumberInactiveProfiles
public static int __GetNumberInactiveProfiles(string connectionStringName, object appName, object inactiveSinceDate)
{
using (var sc = new VzfSqlCommand(connectionStringName))
{
sc.Parameters.Add(sc.CreateParameter(DbType.String, "i_ApplicationName", appName));
sc.Parameters.Add(sc.CreateParameter(DbType.DateTime, "i_InactiveSinceDate", inactiveSinceDate));
sc.Parameters.Add(sc.CreateParameter(DbType.Guid, "i_newguid", Guid.NewGuid()));
sc.CommandText.AppendObjectQuery("prov_profile_getnumberinactiveprofiles", connectionStringName);
return Convert.ToInt32(sc.ExecuteScalar(CommandType.StoredProcedure, false));
}
}
示例5: UpdateUser
/// <summary>
/// The update user.
/// </summary>
/// <param name="connectionString">
/// The connection string.
/// </param>
/// <param name="appName">
/// The app name.
/// </param>
/// <param name="user">
/// The user.
/// </param>
/// <param name="requiresUniqueEmail">
/// The requires unique email.
/// </param>
/// <returns>
/// The <see cref="int"/>.
/// </returns>
public int UpdateUser(string connectionStringName, object appName, MembershipUser user, bool requiresUniqueEmail)
{
// connectionStringName = SqlDbAccess.GetConnectionStringNameFromConnectionString(connectionStringName);
using (var sc = new VzfSqlCommand(connectionStringName))
{
sc.Parameters.Add(sc.CreateParameter(DbType.String, "I_APPLICATIONNAME", appName));
sc.Parameters.Add(sc.CreateParameter(DbType.String, "i_userkey", user.ProviderUserKey));
sc.Parameters.Add(sc.CreateParameter(DbType.String, "I_USERNAME", user.UserName));
sc.Parameters.Add(sc.CreateParameter(DbType.String, "I_EMAIL", user.Email));
sc.Parameters.Add(sc.CreateParameter(DbType.String, "I_COMMENT", user.Comment));
sc.Parameters.Add(sc.CreateParameter(DbType.Boolean, "i_isapproved", user.IsApproved));
sc.Parameters.Add(sc.CreateParameter(DbType.DateTime, "I_LASTLOGIN", user.LastLoginDate));
sc.Parameters.Add(sc.CreateParameter(DbType.DateTime, "I_LASTACTIVITY", user.LastActivityDate));
sc.Parameters.Add(sc.CreateParameter(DbType.Boolean, "I_UNIQUEEMAIL", requiresUniqueEmail));
sc.CommandText.AppendObjectQuery("P_updateuser", connectionStringName);
return Convert.ToInt32(sc.ExecuteScalar(CommandType.StoredProcedure));
}
}
示例6: SetProfilePropertiesOld
public void SetProfilePropertiesOld(string connectionStringName, object appName, object userID, SettingsPropertyValueCollection values, List<SettingsPropertyColumn> settingsColumnsList)
{
using (var sc = new VzfSqlCommand(connectionStringName))
{
bool profileExists = false;
string table =
SqlDbAccess.GetVzfObjectNameFromConnectionString("prov_Profile", connectionStringName);
using (var sc1 = new VzfSqlCommand(connectionStringName))
{
// cmd.Parameters.Add(new FbParameter("@I_USERID", FbDbType.VarChar)).Value = userID;
sc1.CommandText.AppendQuery(string.Format("SELECT COUNT(1) FROM {0} WHERE UserID =UNHEX(REPLACE('{1}','-',''));", table, MySqlHelpers.GuidConverter(new Guid(userID.ToString())).ToString()));
profileExists = Convert.ToBoolean(sc1.ExecuteScalar(CommandType.Text, false));
}
StringBuilder MySqlCommandTextMain =
new StringBuilder("");
sc.Parameters.Add(sc.CreateParameter(DbType.String, "?i_UserID", MySqlHelpers.GuidConverter(new Guid(userID.ToString())).ToString()));
// Build up strings used in the query
StringBuilder columnStr = new StringBuilder();
StringBuilder valueStr = new StringBuilder();
StringBuilder setStr = new StringBuilder();
int count = 0;
foreach (SettingsPropertyColumn column in settingsColumnsList)
{
// only write if it's dirty
if (values[column.Settings.Name].IsDirty)
{
columnStr.Append(", ");
valueStr.Append(", ");
columnStr.Append(column.Settings.Name);
string valueParam = "?Value" + count;
valueStr.Append(valueParam);
sc.Parameters.Add(sc.CreateParameter(column.DataType, valueParam, values[column.Settings.Name].PropertyValue));
if (column.DataType != DbType.DateTime)
{
if (count > 0)
{
setStr.Append(",");
}
setStr.Append(column.Settings.Name);
setStr.Append("=");
setStr.Append(valueParam);
}
count++;
}
}
columnStr.Append(",LastUpdatedDate ");
valueStr.Append(",?LastUpdatedDate");
setStr.Append(",LastUpdatedDate=?LastUpdatedDate");
sc.Parameters.Add(sc.CreateParameter(DbType.DateTime, "?LastUpdatedDate", DateTime.UtcNow));
if (profileExists)
{
MySqlCommandTextMain.Append(" UPDATE ").Append(table).Append(" SET ").Append(setStr.ToString());
MySqlCommandTextMain.Append(" WHERE UserID =UNHEX(REPLACE(@i_UserID,'-',''))");
MySqlCommandTextMain.Append(";");
}
else
{
MySqlCommandTextMain.Append("INSERT INTO ").Append(table).Append(" (UserID").Append(columnStr.ToString());
MySqlCommandTextMain.Append(") VALUES (UNHEX(REPLACE(@i_UserID,'-',''))").Append(valueStr.ToString()).Append(");");
}
sc.Parameters.Add(sc.CreateParameter(DbType.String, "@i_UserID", MySqlHelpers.GuidConverter(new Guid(userID.ToString())).ToString()));
sc.CommandText.AppendQuery(MySqlCommandTextMain.ToString());
sc.ExecuteNonQuery(CommandType.Text, false);
}
}
示例7: SetPropertyValues
//.........这里部分代码省略.........
{
return;
}
// check if profile exits to select insert or update
bool profileExists;
string profileExistsSql;
switch (dataEngine)
{
case SqlDbAccess.MsSql:
profileExistsSql = MsProfile.ProfileExists;
break;
case SqlDbAccess.Npgsql:
profileExistsSql = PgProfile.ProfileExists;
break;
case SqlDbAccess.MySql:
profileExistsSql = MySqlProfile.ProfileExists;
break;
case SqlDbAccess.Firebird:
profileExistsSql = FbProfile.ProfileExists;
break;
default:
throw new ArgumentOutOfRangeException(dataEngine);
}
using (var sc = new VzfSqlCommand(mid))
{
sc.Parameters.Add(sc.CreateParameter(DbType.Int32, "i_UserID", userId));
sc.Parameters.Add(sc.CreateParameter(DbType.String, "i_ApplicationName", appname));
sc.CommandText.AppendQuery(profileExistsSql.FormatWith(SqlDbAccess.GetVzfObjectName(tableName, mid)));
profileExists = Convert.ToInt32(sc.ExecuteScalar(CommandType.Text, true)) > 0;
}
// create data for saving profile properties
string sql;
var paramData = new List<Tuple<DbType, string, object>>();
// Build up strings used in the query
var columnStr = new StringBuilder();
var valueStr = new StringBuilder();
var setStr = new StringBuilder();
spc.ForEach(
column =>
{
if (!collection[column.Settings.Name].IsDirty) return;
var nameParam = collection[column.Settings.Name].Name;
var valParam = collection[column.Settings.Name].PropertyValue;
nameParam = "@i_" + nameParam;
paramData.Add(new Tuple<DbType, string, object>(column.DataType, nameParam, valParam));
valueStr.Append(nameParam);
valueStr.Append(",");
columnStr.Append(column.Settings.Name);
columnStr.Append(",");
setStr.Append(column.Settings.Name);
setStr.Append("=");
setStr.Append(nameParam);
示例8: pollgroup_attach
/// <summary>
/// The pollgroup_attach.
/// </summary>
/// <param name="mid">
/// The mid.
/// </param>
/// <param name="pollGroupId">
/// The poll group id.
/// </param>
/// <param name="topicId">
/// The topic id.
/// </param>
/// <param name="forumId">
/// The forum id.
/// </param>
/// <param name="categoryId">
/// The category id.
/// </param>
/// <param name="boardId">
/// The board id.
/// </param>
/// <returns>
/// The <see cref="int"/>.
/// </returns>
public static int pollgroup_attach(
int? mid,
int? pollGroupId,
int? topicId,
int? forumId,
int? categoryId,
int? boardId)
{
using (var sc = new VzfSqlCommand(mid))
{
sc.Parameters.Add(sc.CreateParameter(DbType.Int32, "i_PollGroupID", pollGroupId));
sc.Parameters.Add(sc.CreateParameter(DbType.Int32, "i_TopicID", topicId));
sc.Parameters.Add(sc.CreateParameter(DbType.Int32, "i_ForumID", forumId));
sc.Parameters.Add(sc.CreateParameter(DbType.Int32, "i_CategoryID", categoryId));
sc.Parameters.Add(sc.CreateParameter(DbType.Int32, "i_BoardID", boardId));
sc.CommandText.AppendObjectQuery("pollgroup_attach", mid);
return Convert.ToInt32(sc.ExecuteScalar(CommandType.StoredProcedure));
}
}
示例9: forum_save_parentschecker
/// <summary>
/// The forum_save_parentschecker.
/// </summary>
/// <param name="mid">
/// The mid.
/// </param>
/// <param name="forumId">
/// The forum id.
/// </param>
/// <param name="parentId">
/// The parent id.
/// </param>
/// <returns>
/// The <see cref="int"/>.
/// </returns>
public static int forum_save_parentschecker(int? mid, object forumId, object parentId)
{
using (var sc = new VzfSqlCommand(mid))
{
sc.Parameters.Add(sc.CreateParameter(DbType.Int32, "i_ForumID", forumId));
sc.Parameters.Add(sc.CreateParameter(DbType.Int32, "i_ParentID", parentId));
sc.CommandText.AppendObjectQuery("forum_save_prntchck", mid);
return Convert.ToInt32(sc.ExecuteScalar(CommandType.StoredProcedure));
}
}
示例10: forum_save
//.........这里部分代码省略.........
/// The image url.
/// </param>
/// <param name="styles">
/// The styles.
/// </param>
/// <param name="dummy">
/// The dummy.
/// </param>
/// <param name="userId">
/// The user id.
/// </param>
/// <param name="isUserForum">
/// The is user forum.
/// </param>
/// <param name="canhavepersforums">
/// The canhavepersforums.
/// </param>
/// <param name="adjacentForumId">
/// The ajacent forum id.
/// </param>
/// <param name="adjacentForumMode">
/// The ajacent forum mode.
/// </param>
/// <returns>
/// The <see cref="long"/>.
/// </returns>
public static long forum_save(
int? mid,
object forumId,
object categoryId,
object parentId,
object name,
object description,
object sortOrder,
object locked,
object hidden,
object isTest,
object moderated,
object accessMaskId,
object remoteUrl,
object themeUrl,
object imageUrl,
object styles,
bool dummy,
object userId,
bool isUserForum,
bool canhavepersforums,
object adjacentForumId,
object adjacentForumMode)
{
using (var sc = new VzfSqlCommand(mid))
{
int sortOrderOut;
if (int.TryParse(sortOrder.ToString(), out sortOrderOut))
{
if (sortOrderOut >= 255)
{
sortOrderOut = 0;
}
}
sc.Parameters.Add(sc.CreateParameter(DbType.Int32, "i_ForumID", forumId));
sc.Parameters.Add(sc.CreateParameter(DbType.Int32, "i_CategoryID", categoryId));
sc.Parameters.Add(sc.CreateParameter(DbType.Int32, "i_ParentID", parentId));
sc.Parameters.Add(sc.CreateParameter(DbType.String, "i_Name", name));
sc.Parameters.Add(sc.CreateParameter(DbType.String, "i_Description", description));
sc.Parameters.Add(sc.CreateParameter(DbType.Int32, "i_SortOrder", sortOrderOut));
sc.Parameters.Add(sc.CreateParameter(DbType.Boolean, "i_Locked", locked));
sc.Parameters.Add(sc.CreateParameter(DbType.Boolean, "i_Hidden", hidden));
sc.Parameters.Add(sc.CreateParameter(DbType.Boolean, "i_IsTest", isTest));
sc.Parameters.Add(sc.CreateParameter(DbType.Boolean, "i_Moderated", moderated));
sc.Parameters.Add(sc.CreateParameter(DbType.String, "i_RemoteURL", remoteUrl));
sc.Parameters.Add(sc.CreateParameter(DbType.String, "i_ThemeURL", themeUrl));
sc.Parameters.Add(sc.CreateParameter(DbType.String, "i_ImageURL", imageUrl));
sc.Parameters.Add(sc.CreateParameter(DbType.String, "i_Styles", styles));
sc.Parameters.Add(sc.CreateParameter(DbType.Int32, "i_AccessMaskID", accessMaskId));
sc.Parameters.Add(sc.CreateParameter(DbType.Int32, "i_UserID", userId));
sc.Parameters.Add(sc.CreateParameter(DbType.Boolean, "i_IsUserForum", isUserForum));
sc.Parameters.Add(sc.CreateParameter(DbType.Boolean, "i_CanHavePersForums", canhavepersforums));
sc.Parameters.Add(sc.CreateParameter(DbType.Int32, "i_AdjacentForumID", adjacentForumId));
sc.Parameters.Add(sc.CreateParameter(DbType.Int32, "i_AdjacentForumMode", adjacentForumMode));
sc.Parameters.Add(sc.CreateParameter(DbType.DateTime, "i_UTCTIMESTAMP", DateTime.UtcNow));
sc.CommandText.AppendObjectQuery("forum_save", mid);
object resultop = sc.ExecuteScalar(CommandType.StoredProcedure);
if (resultop == DBNull.Value)
{
return 0;
}
/* if (Config.LargeForumTree)
{
forum_ns_recreate(mid);
} */
return long.Parse(resultop.ToString());
}
}
示例11: forum_move
/// <summary>
/// The forum_move.
/// </summary>
/// <param name="mid">
/// The mid.
/// </param>
/// <param name="forumOldId">
/// The forum old id.
/// </param>
/// <param name="forumNewId">
/// The forum new id.
/// </param>
/// <returns>
/// The <see cref="bool"/>.
/// </returns>
public static bool forum_move(int? mid, [NotNull] object forumOldId, [NotNull] object forumNewId)
{
using (var sc = new VzfSqlCommand(mid))
{
sc.Parameters.Add(sc.CreateParameter(DbType.Int32, "i_ForumID", forumOldId));
sc.CommandText.AppendObjectQuery("forum_listSubForums", mid);
// if a forum already exists.
if (!(sc.ExecuteScalar(CommandType.StoredProcedure) is DBNull))
{
return false;
}
sc.Parameters.Clear();
sc.CommandText.Clear();
sc.Parameters.Add(sc.CreateParameter(DbType.Int32, "i_ForumOldID", forumOldId));
sc.Parameters.Add(sc.CreateParameter(DbType.Int32, "i_ForumNewID", forumNewId));
sc.CommandText.AppendObjectQuery("forum_move", mid);
// TODO: command timeout should be very large here
sc.ExecuteNonQuery(CommandType.StoredProcedure);
/* if (Config.LargeForumTree)
{
forum_ns_recreate(mid);
} */
return true;
}
}
示例12: category_delete
/// <summary>
/// The category_delete.
/// </summary>
/// <param name="mid">
/// The mid.
/// </param>
/// <param name="categoryId">
/// The category id.
/// </param>
/// <param name="newCategoryId"></param>
/// <returns>
/// The<see cref="bool"/>.
/// </returns>
public static bool category_delete(int? mid, object categoryId, int? newCategoryId)
{
using (var sc = new VzfSqlCommand(mid))
{
sc.Parameters.Add(sc.CreateParameter(DbType.Int32, "i_CategoryID", categoryId));
sc.Parameters.Add(sc.CreateParameter(DbType.Int32, "i_NewCategoryID", newCategoryId));
sc.CommandText.AppendObjectQuery("category_delete", mid);
var res = Convert.ToInt32(sc.ExecuteScalar(CommandType.StoredProcedure)) != 0;
/* if (Config.LargeForumTree)
{
forum_ns_recreate(mid);
} */
return res;
}
}
示例13: buddy_remove
/// <summary>
/// The buddy_remove.
/// </summary>
/// <param name="mid">
/// The mid.
/// </param>
/// <param name="fromUserId">
/// The from user id.
/// </param>
/// <param name="toUserId">
/// The to user id.
/// </param>
/// <returns>
/// The <see cref="string"/>.
/// </returns>
public static string buddy_remove(int? mid, object fromUserId, object toUserId)
{
using (var sc = new VzfSqlCommand(mid))
{
sc.Parameters.Add(sc.CreateParameter(DbType.Int32, "i_FromUserID", fromUserId));
sc.Parameters.Add(sc.CreateParameter(DbType.Int32, "i_ToUserID", toUserId));
sc.Parameters.Add(sc.CreateParameter(DbType.Boolean, "i_UseDisplayName", true));
sc.CommandText.AppendObjectQuery("buddy_remove", mid);
return sc.ExecuteScalar(CommandType.StoredProcedure).ToString();
}
}
示例14: buddy_approveRequest
/// <summary>
/// The buddy_approve request.
/// </summary>
/// <param name="mid">
/// The mid.
/// </param>
/// <param name="fromUserId">
/// The from user id.
/// </param>
/// <param name="toUserId">
/// The to user id.
/// </param>
/// <param name="mutual">
/// The mutual.
/// </param>
/// <returns>
/// The <see cref="string"/>.
/// </returns>
public static string buddy_approveRequest(int? mid, object fromUserId, object toUserId, object mutual)
{
using (var sc = new VzfSqlCommand(mid))
{
sc.Parameters.Add(sc.CreateParameter(DbType.Int32, "i_FromUserID", fromUserId));
sc.Parameters.Add(sc.CreateParameter(DbType.Int32, "i_ToUserID", toUserId));
sc.Parameters.Add(sc.CreateParameter(DbType.Boolean, "i_Mutual", mutual));
sc.Parameters.Add(sc.CreateParameter(DbType.Boolean, "i_UseDisplayName", true));
sc.Parameters.Add(sc.CreateParameter(DbType.DateTime, "i_UTCTIMESTAMP", DateTime.UtcNow));
sc.CommandText.AppendObjectQuery("buddy_approverequest", mid);
return sc.ExecuteScalar(CommandType.StoredProcedure).ToString();
}
}
示例15: board_save
/// <summary>
/// The board_save.
/// </summary>
/// <param name="mid">
/// The mid.
/// </param>
/// <param name="boardId">
/// The board id.
/// </param>
/// <param name="languageFile">
/// The language file.
/// </param>
/// <param name="culture">
/// The culture.
/// </param>
/// <param name="name">
/// The name.
/// </param>
/// <param name="allowThreaded">
/// The allow threaded.
/// </param>
/// <returns>
/// The <see cref="int"/> id of a saved board.
/// </returns>
public static int board_save(
int? mid,
object boardId,
object languageFile,
object culture,
object name,
object allowThreaded)
{
using (var sc = new VzfSqlCommand(mid))
{
sc.Parameters.Add(sc.CreateParameter(DbType.Int32, "i_BoardID", boardId));
sc.Parameters.Add(sc.CreateParameter(DbType.String, "i_Name", name));
sc.Parameters.Add(sc.CreateParameter(DbType.String, "i_LanguageFile", languageFile));
sc.Parameters.Add(sc.CreateParameter(DbType.String, "i_Culture", culture));
sc.Parameters.Add(sc.CreateParameter(DbType.Boolean, "i_AllowThreaded", allowThreaded));
sc.CommandText.AppendObjectQuery("board_save", mid);
return Convert.ToInt32(sc.ExecuteScalar(CommandType.StoredProcedure));
}
}