本文整理汇总了C#中DbHelper.ExecuteNonQuery方法的典型用法代码示例。如果您正苦于以下问题:C# DbHelper.ExecuteNonQuery方法的具体用法?C# DbHelper.ExecuteNonQuery怎么用?C# DbHelper.ExecuteNonQuery使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类DbHelper
的用法示例。
在下文中一共展示了DbHelper.ExecuteNonQuery方法的11个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C#代码示例。
示例1: CreateProcedure
/// summary
/// �������ݿ�洢����
/// /summary
/// param name="procedureName"�洢������/param
/// param name="procedureText"�洢��������/param
public override void CreateProcedure(string procedureName, string procedureText)
{
if(procedureText != null && procedureText.Trim() != "")
{
DropProcedure(procedureName);
DbHelper helper = new DbHelper();
helper.ExecuteNonQuery(procedureText);
}
}
示例2: CreateFunction
/// summary
/// �������ݿ⺯��
/// /summary
/// param name="functionName"������/param
/// param name="functionText"��������/param
public override void CreateFunction(string functionName, string functionText)
{
if(functionText != null && functionText.Trim() != "")
{
DropFunction(functionName);
DbHelper helper = new DbHelper();
helper.ExecuteNonQuery(functionText);
}
}
示例3: Insert
public bool Insert(User tModel) {
using (SqlCommand command = new DbHelper().Command) {
command.CommandText =
"insert into eduuser(userid,userpass,name,age,birthday) values (@userid,@userpass,@name,@age,@birthday)";
command.Parameters.AddRange(CreateSqlParameters(tModel));
int ret = command.ExecuteNonQuery();
return ret > 0;
}
}
示例4: Insert
public bool Insert(User_Model tModel) {
using (SqlCommand command = new DbHelper().Command) {
command.CommandText =
$"insert into {Table}(UserID,[Password],Name,Sex,Birthday,Email) values (@UserID,@Password,@Name,@Sex,@Birthday,@Email)";
command.Parameters.AddRange(CreateSqlParameters(tModel));
int ret = command.ExecuteNonQuery();
return ret > 0;
}
}
示例5: InsertBatch
public int InsertBatch(List<User> tModels, bool tran = false) {
using (SqlCommand command = new DbHelper().Command) {
try {
if (tran) {
command.Transaction = command.Connection.BeginTransaction();
}
int ret = 0;
foreach (User tModel in tModels) {
command.CommandText =
"insert into eduuser(userid,userpass,name,age,birthday) values (@userid,@userpass,@name,@age,@birthday)";
command.Parameters.Clear();
command.Parameters.AddRange(CreateSqlParameters(tModel));
ret += command.ExecuteNonQuery();
}
if (tran) {
command.Transaction.Commit();
}
return ret;
}
catch (Exception ex) {
if (tran) {
command.Transaction.Rollback();
}
XK.Common.Log4net.Error(ex);
return 0;
}
}
}
示例6: CreateView
/// summary
/// �������ݿ���ͼ
/// /summary
/// param name="viewName"��ͼ��/param
/// param name="viewText"��ͼ����/param
public override void CreateView(string viewName, string viewText)
{
if(viewText != null && viewText.Trim() != "")
{
DropView(viewName);
DbHelper helper = new DbHelper();
helper.ExecuteNonQuery(viewText);
}
}
示例7: EnableTrigger
/// summary
/// Enable������
/// /summary
/// param name="triggerName"����������/param
/// param name="tableName"���������ڱ���/param
public override void EnableTrigger(string triggerName,string tableName)
{
string commandText = string.Format("alter table {0} enable trigger {1}",tableName,triggerName);
DbHelper helper = new DbHelper();
helper.ExecuteNonQuery(commandText);
}
示例8: EnablePKConstraint
/// summary
/// Enable����
/// /summary
/// param name="pkTableName"������/param
/// param name="pkConstraint"����/param
/// param name="pkField"�����ֶ�/param
public override void EnablePKConstraint(string pkTableName,string pkConstraint,string pkField)
{
string commandText = string.Format("alter table {0} enable constraint {1}",
pkTableName,pkConstraint);
DbHelper helper = new DbHelper();
helper.ExecuteNonQuery(commandText);
}
示例9: DisableFKConstraint
/// summary
/// Disable���
/// /summary
/// param name="fkTableName"�����/param
/// param name="fkConstraint"���/param
public override void DisableFKConstraint(string fkTableName,string fkConstraint)
{
string commandText = string.Format("alter table {0} disable constraint {1}",
fkTableName,fkConstraint);
DbHelper helper = new DbHelper();
helper.ExecuteNonQuery(commandText);
}
示例10: InsertBatch
public int InsertBatch(List<User_Model> tModels, bool tran = false) {
using (SqlCommand command = new DbHelper().Command) {
try {
if (tran) {
command.Transaction = command.Connection.BeginTransaction();
}
int ret = 0;
foreach (User_Model tModel in tModels) {
command.CommandText =
$"insert into {Table}(UserID,[Password],Name,Sex,Birthday,Email) values (@UserID,@Password,@Name,@Sex,@Birthday,@Email)";
command.Parameters.Clear();
command.Parameters.AddRange(CreateSqlParameters(tModel));
ret += command.ExecuteNonQuery();
}
if (tran) {
command.Transaction.Commit();
}
return ret;
}
catch (Exception ex) {
if (tran) {
command.Transaction.Rollback();
}
XK.Common.Log4net.Error(ex);
return 0;
}
}
}
示例11: EnsureSessionUserConsistence
public void EnsureSessionUserConsistence()
{
DbHelper dbHelper = new DbHelper();
DbCommand comannd = dbHelper.BuildDbCommand("P_IC_SESSIONS_CHECK_USER_NAME");
dbHelper.AssignParameterValues(comannd, AppContext.Current.SessionID, AppContext.Current.UserName);
dbHelper.ExecuteNonQuery(comannd);
bool isKilled = (bool)dbHelper.GetParameterValue(comannd, "p_is_killed");
bool userSessionMatched = (bool)dbHelper.GetParameterValue(comannd, "p_user_session_matched");
if (isKilled)
{
throw new SessionRenewException(Messages.Framework.FWE003.Format(), SessionStatus.Killed);
}
if (!userSessionMatched)
{
throw new SessionRenewException(Messages.Framework.FWE006.Format(), SessionStatus.NotMatchUserName);
}
}