Hỏi về LinQ to SQL

Superman264

Junior Member
em có procedure:
create proc [dbo].[Dang_nhap_insect]
(
@username nvarchar(50),
@password nvarchar(50)
)
as
begin
insert into DangNhap(UserName,pass) values (@Username,@password)
end

hàm trong C# em dung như thê này:
dt.Dang_nhap_insect(txtUsernam.Text,Txtpass.Text);
Có cách nào để mình kiểm tra đã thêm thành công vào CSDL ko ạ.
 
- bạn viết hàm proc viết thêm cái này SET @NewId = SCOPE_IDENTITY() nó sẽ trả về thằng id insert rồi nó return về hàm của bạn lúc gọi thằng procedure là sẽ get được.
- bạn nghiên cứu entity framework đi dùng ngon hơn thằng linq to sql nhiều với lại đặt tên hàm bằng tiếng anh và theo convention c# của microsoft.
link convention c#:
https://docs.microsoft.com/en-us/dotnet/csharp/programming-guide/inside-a-program/coding-conventions
 
Back
Top