本文整理汇总了C#中System.Data.SqlClient.SqlCommand.AddWithValue方法的典型用法代码示例。如果您正苦于以下问题:C# SqlCommand.AddWithValue方法的具体用法?C# SqlCommand.AddWithValue怎么用?C# SqlCommand.AddWithValue使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类System.Data.SqlClient.SqlCommand
的用法示例。
在下文中一共展示了SqlCommand.AddWithValue方法的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C#代码示例。
示例1: Delete
public override int Delete(long ID)
{
SqlParameterCollection prms = new SqlCommand().Parameters;
prms.AddWithValue("@ID", ID);
prms.AddWithValue("@controlID", mArchiveControl.ID);
return squtil.ExecuteNoResultSetSQLQuery(deleteSql, prms);
}
示例2: AddUserAndRoles
static public void AddUserAndRoles(string newStaffUserName)
{
var environmentParametersViewModel = new Thinkgate.Domain.Classes.EnvironmentParametersFactory(AppSettings.ConnectionStringName).GetEnvironmentParameters();
var clientId = environmentParametersViewModel.ClientId;
var kenticoEnabled = environmentParametersViewModel.IsKenticoEnabledSite;
if (kenticoEnabled)
{
SqlParameterCollection parmsUersInRoles = new SqlCommand().Parameters;
parmsUersInRoles.AddWithValue("ApplicationName", AppSettings.ApplicationName);
parmsUersInRoles.AddWithValue("UserName", newStaffUserName);
var findRolesForUser = ThinkgateDataAccess.FetchDataTable(AppSettings.ConnectionString,
Thinkgate.Base.Classes.Data.StoredProcedures.ASPNET_USERS_IN_ROLES_GET_ROLES_FOR_USER,
System.Data.CommandType.StoredProcedure,
parmsUersInRoles);
var roleservice = new RoleServiceProxy();
var nameCalculator = new Thinkgate.Domain.Classes.KenticoNameCalculator();
for (int i = 0; i < findRolesForUser.Rows.Count; i++)
{
string newStaffRoleName = findRolesForUser.Rows[i]["RoleName"].ToString();
var kenticoUserName = nameCalculator.CalculateUserName(clientId, newStaffUserName);
var kenticoRoleName = nameCalculator.CalculateSystemGroupName(clientId, AdminUserName, newStaffRoleName);
var roleuser = new RoleUser();
roleuser.UserName = kenticoUserName;
roleservice.AddUsersToRole(kenticoRoleName, EnumerableExtensions.SingleItemAsEnumerable<RoleUser>(roleuser));
}
}
}
示例3: Read
public override byte[] Read(long ID)
{
SqlParameterCollection prms = new SqlCommand().Parameters;
prms.AddWithValue("@ID", ID);
prms.AddWithValue("@controlID", mArchiveControl.ID);
return (byte[])squtil.ExecuteScalarResultSetSQLQuery(selectSql, prms);
}
示例4: InsertData2
public int InsertData2()
{
var arrayOfParameter = new SqlCommand().Parameters;
arrayOfParameter.AddWithValue("@rollno", _rollNo);
arrayOfParameter.AddWithValue("@name", _name);
arrayOfParameter.AddWithValue("@department", _department);
arrayOfParameter.AddWithValue("@section", _section);
return this.ModifyDataStoredProcedure(@"USP_StudentDetailsProc4", arrayOfParameter);
}
示例5: WithReturn3
public int WithReturn3()
{
var arrayOfParameter = new SqlCommand().Parameters;
arrayOfParameter.AddWithValue("@rico", _rico);
return this.ModifyDataStoredProcedureWithReturn(@"USP_StudentDetailsProc6", arrayOfParameter);
}
示例6: getLoginTeams
public DataTable getLoginTeams()
{
DataTable dt = new DataTable();
var oParam = new SqlCommand().Parameters;
oParam.AddWithValue("@workdayid", _workdayid);
return dt = _dbi.FGetDataTable(@"EmployeeGetTeams", oParam);
}
示例7: GetAllDetailsByName
public DataTable GetAllDetailsByName()
{
var arrayOfParameter = new SqlCommand().Parameters;
arrayOfParameter.AddWithValue("@name", _name);
return this.GetDataStoredProcedure(@"USP_StudentDetailsProc2", arrayOfParameter );
}
示例8: getLoginDetails
public DataSet getLoginDetails(string lanid)
{
DataSet ds = new DataSet();
lanid = lanid.Remove(0, lanid.IndexOf('\\') + 1);
var oParam = new SqlCommand().Parameters;
oParam.AddWithValue("@lanid", lanid);
return ds = _dbi.FGetDataSet(@"EmployeeDetailsDisplay", oParam);
}
示例9: ReadHash
public override Dictionary<string, object> ReadHash(long ID)
{
//cant use GT cause GT calls archive to read data and that would create a recursive loop
SqlParameterCollection prms = new SqlCommand().Parameters;
prms.AddWithValue("@id", ID);
DataTable dt = squtil.ExecuteSingleResultSetSQLQuery(String.Format("select * from {0} where {1} = @id", dbTable, mArchiveControl.cfg.IDColumn), prms);
if (dt.Rows.Count == 0)
return null;
GenericTable gt = new GenericTable(squtil, dbTable, mArchiveControl.cfg.IDColumn);
gt.Load(dt.Rows[0]);
//this was not archived - it was just put there so we have the ability to archive that data
if (this.mArchiveControl.ArchiveType == ArchiveControl.ArchiveTypeEnum.Column)
gt.Data.Remove(mArchiveControl.cfg.AgeDeterminingColumn);
return gt.Data;
}
示例10: displayKhronosLogs
public DataTable displayKhronosLogs(int x)
{
DataTable dt = new DataTable();
var oParam = new SqlCommand().Parameters;
//oParam.AddWithValue("@teamid", _teamid);
oParam.AddWithValue("@workdayid", _employeeid);
//oParam.AddWithValue("@month", _month);
oParam.AddWithValue("@monthyear", _monthYear);
//oParam.AddWithValue("@year", _year);
if (x == 1)
{
//return dt = this.FGetDataTable(@"KhronosTeamLogsBMDisplay", oParam);
return dt = this.FGetDataTable(@"GetEmployeeLogs", oParam);
}
else
{
return dt = this.FGetDataTable(@"KhronosEmployeeTardiness", oParam);
//return dt = this.FGetDataTable(@"KhronosTeamLogsDLDisplay", oParam);
}
}
示例11: cancelShift
public string cancelShift()
{
var oParam = new SqlCommand().Parameters;
oParam.AddWithValue("@shiftempid", _shiftempid);
this.FExecuteQuery("EmployeeShiftCancel", oParam);
return "done";
}
示例12: cancelLeaves
public string cancelLeaves()
{
var oParam = new SqlCommand().Parameters;
oParam.AddWithValue("@leaveid", _leaveid);
oParam.AddWithValue("@workdayid", _employeeid);
this.FExecuteQuery(@"KhronosEmployeeLeaveCancel", oParam);
return "done";
}
示例13: InsertForecast
public string InsertForecast()
{
string msg;
var oParam = new SqlCommand().Parameters;
oParam.AddWithValue("@teamid", _teamid);
oParam.AddWithValue("@position", _position);
oParam.AddWithValue("@year", _year);
oParam.AddWithValue("@month", _month);
oParam.AddWithValue("@teamname", _teamname);
//oParam.AddWithValue("@count", _count);
try
{
this.ExecuteInsert(@"HCInsertForecast", oParam);
msg = "Saved!";
}
catch (Exception ex)
{
msg = ex.ToString();
}
return msg;
}
示例14: insertLeaves
public string insertLeaves()
{
var oParam = new SqlCommand().Parameters;
oParam.AddWithValue("@teamempid", _teamempid);
oParam.AddWithValue("@leavetype", _leavetype);
oParam.AddWithValue("@leavedate", _leavedate);
oParam.AddWithValue("@leavevolume", _leavevolume);
oParam.AddWithValue("@leavereason", _leavereason);
oParam.AddWithValue("@workdayid", _employeeid);
this.ExecuteInsert(@"KhronosEmployeeLeavesInsert", oParam);
return "done";
}
示例15: getEmployeeShift
public DataTable getEmployeeShift()
{
DataTable dt = new DataTable();
var oParam = new SqlCommand().Parameters;
oParam.AddWithValue("@teamempid", _teamempid);
oParam.AddWithValue("@shiftstartdate", _shiftstartdate);
oParam.AddWithValue("@shiftenddate", _shiftenddate);
return dt = this.FGetDataTable(@"EmployeeShiftGet", oParam);
}