ASP.NET MVC – #5: Tạo trang đăng nhập qua Store Procedure | Login with Store procedure | TEDU

25
37



Mã nguồn bài học Onlineshop:
Khóa học làm dự án thực tế với ASP.NET MVC, WebAPI, AngularJS:
Trong bài học này mình sẽ hướng dẫn các bạn các bước sau:
– Ghép giao diện trang login vào hệ thống
– Tạo mới Login Model
– Tạo tầng Models và cài đặt Entity Framework
– Tạo tầng Code first bằng Entity Framwork tool for Visual
– Tao view Login bằng HTML Razor
– Login và thông báo lỗi bằng Razor

Để tham khảo cách đăng nhập qua Entity linq các bạn xem video này:

Mội số lỗi: No connection string named ‘xxx’ could be found in the application config file. Các bạn nên copy chuỗi connection string được tự gen ra trong App.config sang web.config. Vì khi chạy web thì connection sẽ được đọc ở web.config
Lỗi 2:
Additional information: No Entity Framework provider found for the ADO.NET provider with invariant name ‘System.Data.SqlClient’. Make sure the provider is registered in the ‘entityFramework’ section of the application config file. See for more information.

Là do chưa cài Entity Framework cho project

ASP.NET MVC – #5: Tạo trang đăng nhập qua Store Procedure | Login with Store procedure | TEDU

▶ More information about TEDU:
Website:
Hotline: 0966 036 626
Email: tedu.international@gmail.com

▶ CLICK TO SUBSCRIBE:
#tedu #aspnetmvc #mvc

DO NOT REUPLOAD

Nguồn: https://technewsgator.com

Xem thêm bài viết khác: https://technewsgator.com/lap-trinh/

25 COMMENTS

  1. ad ơi cho em hỏi em bi lỗi này mặc dù cái procedure đó nó nằm ở trong sql ạ System.Data.SqlClient.SqlException: 'Could not find stored procedure 'Sp_AccountLogin'.'

  2. ad ơi e làm tới phút 12:47 thì nó ko nhận accountmodel, nó hiện như vậy class-is-inaccessible-due-to-its-protection-level. ad giúp e xử lý với

  3. mình bị dính lỗi như này : <%@ Application Codebehind="Global.asax.cs" Inherits="Webbanhang.Global" Language="C#" %>

    visual: 2019; Microsoft .NET Framework Version:4.0.30319; ASP.NET Version:4.8.4075.0

  4. Cho mình hỏi có ai bị lỗi này k ạ? fix như nào vậy ạ?
    No mapping exists from object type System.Data.SqlClient.SqlParameter[] to a known managed provider native type.

  5. Tedu ơi, mình chạy thì bị lỗi could not find stored procedure. Trong SQL server mình đã tạo rồi, connectionString cũng đã add, mà không chạy được

  6. Mình xin được update thêm 1 chút nữa là cái đoạn viết Store Procedure khi bạn count số user ra thì nên select limit 1 để cho tối ưu câu SQL bạn nhỉ ? 🙂

  7. cho em hỏi lỗi "No Entity Framework provider found for the ADO.NET provider with invariant name 'System.Data.SqlClient'. Make sure the provider is registered in the 'entityFramework' section of the application config file. See http://go.microsoft.com/fwlink/?LinkId=260882 for more information." sửa như nào ạ

  8. Anh ơi bị lỗi này như nào ạ System.InvalidOperationException: 'No connection string named 'BookStoreDbContext' could be found in the application config file.'

  9. mình thấy nói khó nghe quá.kiểu các câu chữ ko rõ ràng :(( kiểu câu được câu không.lại nhiều khái niệm mới.nghe đi nghe lại vẫn ù ù cạc cạc :((

  10. anh ơi cho em hỏi với ạ. khi em chạy nó hiện lên
    No connection string named 'OnlineResDbContect' could be found in the application config file.
    nhưng chuoix kết nối có trong app.config trong class libary Model. cho em hỏi cách sửa với ạ

  11. USE [OnlineShopping]

    GO

    /**** Object: StoredProcedure [dbo].[Sp_Account_Login] Script Date: 12/19/2019 3:57:36 PM ******/

    SET ANSI_NULLS ON

    GO

    SET QUOTED_IDENTIFIER ON

    GO

    ALTER PROCEDURE [dbo].[Sp_Account_Login]

    @Username nvarchar(50),

    @Password nvarchar(50)

    AS

    BEGIN

    declare @count int

    declare @res bit

    select @count =count(*) from Account where Username = @Username and Password = @Password

    if @count>0

    set @res=1

    else

    set @res=0

    select @res

    END

    sao em chuột phải chọn modify ở proc lại bi lõi ở cái ALTER PROCEDURE [dbo].[Sp_Account_Login]

    a nhỉ! xEm hộ em cái

  12. <Chắc ai đó sẽ cần>
    use [OnlineShop]

    go

    SET ANSI_NULLS ON

    GO

    SET QUOTED_IDENTIFIER ON

    GO

    create proc [dbo].[Sp_Account_Login]

    @UserName nvarchar(20),

    @PassWord nvarchar(50)

    as

    begin

    declare @count int

    declare @res bit

    select @count =count(*) from Account where UserName = @UserName and PassWord=@PassWord

    if @count >0

    set @res=1

    else

    set @res=0

    select @res

    end

  13. sao anh gõ code VS tự động import các dòng using vậy ạ. Anh có sử dụng tool gì không chỉ em với ạ

  14. 10:35 các biến @UserName và @Password ở đâu ra vậy anh. Trước em k thấy anh khai báo gì cả

LEAVE A REPLY

Please enter your comment!
Please enter your name here