本文整理汇总了C#中DataProvider.ExecuteProcNonQuery方法的典型用法代码示例。如果您正苦于以下问题:C# DataProvider.ExecuteProcNonQuery方法的具体用法?C# DataProvider.ExecuteProcNonQuery怎么用?C# DataProvider.ExecuteProcNonQuery使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类DataProvider
的用法示例。
在下文中一共展示了DataProvider.ExecuteProcNonQuery方法的1个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C#代码示例。
示例1: Index
public ActionResult Index(TaiKhoan taikhoan)
{
try
{
if (taikhoan.MatKhau.Equals(taikhoan.XacNhanMatKhau))
{
taikhoan.NgayDangKy = DateTime.Now;
taikhoan.LoaiTaiKhoan = LoaiTaiKhoan.Member;
taikhoan.TrangThai = TrangThaiTaiKhoan.Active;
using (MD5 md5hash = MD5.Create())
{
string hash = GetMd5Hash(md5hash, taikhoan.MatKhau);
taikhoan.MatKhau = hash;
}
DataProvider dp = new DataProvider();
SqlParameter[] param = new SqlParameter[9];
param[0] = new SqlParameter("@email", SqlDbType.NVarChar);
param[0].Value = taikhoan.Email;
param[1] = new SqlParameter("@matkhau", SqlDbType.NVarChar);
param[1].Value = taikhoan.MatKhau;
param[2] = new SqlParameter("@maloaitaikhoan", SqlDbType.Int);
param[2].Value = taikhoan.LoaiTaiKhoan;
param[3] = new SqlParameter("@ten", SqlDbType.NVarChar);
param[3].Value = taikhoan.Ten;
param[4] = new SqlParameter("@ngaysinh", SqlDbType.DateTime);
if (taikhoan.NgaySinh == null )
param[4].Value = DBNull.Value;
else
param[4].Value = taikhoan.NgaySinh;
param[5] = new SqlParameter("@diachi", SqlDbType.NVarChar);
if (taikhoan.DiaChi == null)
{
param[5].Value = DBNull.Value;
}
else
{
param[5].Value = taikhoan.DiaChi;
}
param[6] = new SqlParameter("@dienthoai", SqlDbType.NVarChar);
if (taikhoan.DienThoai == null)
{
param[6].Value = DBNull.Value;
}
else { param[6].Value = taikhoan.DienThoai; }
param[7] = new SqlParameter("@ngaydangky", SqlDbType.DateTime);
param[7].Value = taikhoan.NgayDangKy;
param[8] = new SqlParameter("@trangthai", SqlDbType.Int);
param[8].Value = (int)taikhoan.TrangThai;
dp.ExecuteProcNonQuery("sp_DangKyTaiKhoan",ref param);
ViewBag.Result = true;
ViewBag.ErrorMessage = "";
}
else
{
ViewBag.Result = false;
ViewBag.ErrorMessage = "Xác nhận mật khẩu không trùng khớp";
}
}
catch (Exception ex)
{
ViewBag.Result = false;
ViewBag.ErrorMessage = ex.Message;
}
return View("~/Views/Login/DangKy.cshtml");
}