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

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

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

Cross Platform Mobile App: Demo shop with flutter

Cross Platform Mobile App: Demo shop with flutter So cool framework from google <3  Demo:  Demo Code console.print("hello")