Skip to main content

Load CSDL SQL server ASP.NET


Tạo cơ sở dữ liệu




VIDEO


Tạo 1 class để thao tác với sơ sơ dữ liệu
PHP:
public class DataService
    
{
        
string chuoiketnoi ConfigurationManager.ConnectionStrings["QLBH"].ConnectionString;
        
SqlConnection ketnoi;
        public 
DataService()
        {
        }
        public  
void MoKetNoi()
        {
            
ketnoi = new SqlConnection(chuoiketnoi);
            
ketnoi.Open();
        }
        public 
void DongKetNoi()
        {
            
ketnoi.Close();
        }
        public 
bool KTDangNhap(string userstring pas)
        {
            
MoKetNoi();
            
SqlCommand comand = new SqlCommand("select * from nguoidung where TenDangNhap = '"+user+"' and MatKhau='"+pas+"'"ketnoi);
            
SqlDataReader redercomand.ExecuteReader();
            
bool kn false;
            if (
reder.HasRows == truekntrue;
            
DongKetNoi();
            return 
kn;
        }
        public 
string LayHoTen(string userstring pas)
        {
            
MoKetNoi();
            
SqlCommand comand = new SqlCommand("select HoTen from nguoidung where TenDangNhap = '" user "' and MatKhau='" pas "'"ketnoi);
            
String hoten=  comand.ExecuteScalar().ToString(); // trả về 1 dòng đầu tiên của bảng dữ liệu
            
DongKetNoi();
            return 
hoten;
        }
        public 
int LayMaQuyen(string user)
        {
            
MoKetNoi();
            
SqlCommand comand = new SqlCommand("select MaQuyen from nguoidung where TenDangNhap = '" user "'"ketnoi);
            
int q =int.Parse(comand.ExecuteScalar().ToString()); // trả về 1 dòng đầu tiên của bảng dữ liệu
            
DongKetNoi();
            return 
q;
        }
    }

Comments

Popular posts from this blog

Bài tập thuật toán C/C++ Và Tuyển tập đề thi olympic

Gồm: +  Các thuật toán của Lê Minh Hoàng + Tuyển tập các đề thi olympic tin học sinh viên Link down: Tại đây

Socket Android Client to PC Server C#

Using AsynCallback C# Android Client connect Server C# Source code:  http://ow.ly/OlXj309O1mj c# socket multi client, socket c# example, socket server c#, socket c# tutorial, asynchronous socket in c#, c# socket multiple clients, c# socket server multiple clients, Download source code:  Click Here

Mẹo và giải thuật C# dành cho người mới bắt đầu

Với nội dung kiến thức cơ bản nhất. Gồm 31 trang với những nội dung:  1. Kết nối CSDL SQL  -----------How to Create SQL Connection in C# 2. Đọc ghi file text với C#  -----------How to Write Text to a Txt File in C# -----------How to Read Text from a TXT File 3. Xóa Cookie C# -----------How to Delete Cookie Using C# 4. Gửi main sử dụng tài khoàn Gmail với C# -----------How to Send Email Using Your Gmail Account in C# 5. Kiểm tra ký tự nhập vào từ bàn  phím -----------How to Check If a Key Is Pressed In C# 6. Đổi tên file trong C# -----------How to Rename a File Using C# 7. Vô hiệu hóa chuột trong ô textbox C# -----------How to Disable Right Click in C# Textbox 8. Chọn tất cả trong listbox -----------How to Add Select All Button or Checkbox in CheckedListBox 9. Tạo mới thư mục bằng C# -----------How to Create a New Folder Using C# 10. Lấy các tiến trình đang chạy C# ----------- How to Get List of All the Running  Processes in C# 11. Tả...