Đây là source code đăng nhập và hiện thị thông tin của sinh viên bao gồm kết nối cơ sở dữ liệu:
using System;
using System.Collections.Generic;
using System.ComponentModel;
using System.Data;
using System.Drawing;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
using System.Windows.Forms;
using System.Data.SqlClient;
namespace Login
{
public partial class Form1 : Form
{
public Form1()
{
InitializeComponent();
}
private void Form1_Load(object sender, EventArgs e)
{
}
private void btnlogin_Click(object sender, EventArgs e)
{
SqlConnection con2 = new SqlConnection(@"Data Source = WELCOM - PC\SQLEXPRESS; Initial Catalog = Test; Integrated Security = True");
SqlDataAdapter sdt = new SqlDataAdapter("Select Cont (*) from login where id='"+txtid.Text+"'and pass = '"+txtpass.Text+"' ",con2);
DataTable dt = new DataTable();
if(dt.Rows[0][0].ToString()=="1")
{
this.Hide();
Form3 ss = new Form3();
ss.Show();
}
else
{
MessageBox.Show("Login Failed");
}
}
private void chcheck_CheckedChanged(object sender, EventArgs e)
{
if (chcheck.Checked)
{
txtpass.UseSystemPasswordChar = false;
}
else
{
txtpass.UseSystemPasswordChar = true;
}
}
}
}
Thông tin sinh viên:
using System;
using System.Collections.Generic;
using System.ComponentModel;
using System.Data;
using System.Drawing;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
using System.Windows.Forms;
using System.Data.SqlClient;
namespace Login
{
public partial class Form3 : Form
{
SqlConnection conn;
public Form3()
{
InitializeComponent();
}
private void Form3_Load(object sender, EventArgs e)
{
string constring = @"Data Source=WELCOM-PC\SQLEXPRESS;Initial Catalog=Test;Integrated Security=True";
conn = new SqlConnection(constring);
conn.Open();
HienThi();
}
private void Form3_FormClosing(object sender, FormClosingEventArgs e)
{
conn.Close();
}
public void HienThi()
{
string sqlselect = "Select From hocsinh";
SqlCommand cmd = new SqlCommand(sqlselect, conn);
SqlDataReader dr = cmd.ExecuteReader();
DataTable dt = new DataTable();
dt.Load(dr);
dssv.DataSource = dt;
}
private void btnadd_Click(object sender, EventArgs e)
{
}
}
}
Lỗi của mình gặp phải là Progam doesnot contain a static Main method suitable for enty point? ai giúp mình với