当前位置: 首页>>代码示例>>C#>>正文


C# SqlHelper.sql2result方法代码示例

本文整理汇总了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);
            }
        }
开发者ID:hahalin,项目名称:mvc_tutorial,代码行数:44,代码来源:DepartmentController.cs


注:本文中的System.Data.SqlHelper.sql2result方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。