本文整理汇总了C#中System.Data.SqlHelper.sql2result方法的典型用法代码示例。如果您正苦于以下问题:C# SqlHelper.sql2result方法的具体用法?C# SqlHelper.sql2result怎么用?C# SqlHelper.sql2result使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类System.Data.SqlHelper
的用法示例。
在下文中一共展示了SqlHelper.sql2result方法的1个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C#代码示例。
示例1: Create
public ActionResult Create(department model)
{
SqlHelper hp = new SqlHelper();
int icount = 0;
icount=Convert.ToInt32(hp.sql2result("select count(id) from dep where id=" + model.id));
if (icount>0)
{
ModelState.AddModelError("", "部門編號"+model.id+"已經存在");
}
icount = Convert.ToInt32(hp.sql2result("select count(cname) from dep where cname='" + model.departmentName+"'"));
if (icount > 0)
{
ModelState.AddModelError("", "部門名稱" + model.departmentName + "已經存在");
}
/*
if (model.departmentName=="業務部")
{
ModelState.AddModelError("", "該部門名稱已經存在");
}
*/
if (ModelState.IsValid)
{
//寫入資料庫的程式碼
hp.sql2result(
string.Format("insert into dep (id,cname) values ({0},'{1}')",
model.id,model.departmentName
)
);
//
return RedirectToAction("Department", "admin");
}
else
{
return View(model);
}
}