Question
I'm logging in with the id and password I got from the database. I am printing the information of the person whose id is entered
I'm logging in with the id and password I got from the database.
I am printing the information of the person whose id is entered in the newly opened form.
In the form I opened, I want to pull the following information from the database to the datagridview.
datagriedview 1 = courses with which id i logged in with that id is registered.
datagriedview 2 = See other students enrolled in the class
I put the c# codes I wrote under the form
for Student login
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.SQLite;
namespace Term_Project { public partial class SLogin : Form { SQLiteCommand cmd; SQLiteDataReader dr; SQLiteConnection conn;
public SLogin() { conn = new SQLiteConnection("Data Source=C:\\Users\\BERKAY\\Desktop\\TermDB.db; Version=3");
InitializeComponent(); }
private void button1_Click(object sender, EventArgs e) { string user = textBox1.Text; string pass = textBox2.Text; cmd = new SQLiteCommand(); conn.Open(); cmd.Connection = conn; cmd.CommandText = "Select * From Student Where ID=" + user + " AND Password=" + pass + ""; dr = cmd.ExecuteReader();
if (dr.Read()) { MessageBox.Show("Login Success."); Student std = new Student(Convert.ToInt32(dr.GetValue(0).ToString()),dr.GetValue(1).ToString(),dr.GetValue(2).ToString(),dr.GetValue(3).ToString()); std.Show(); this.Hide();
} else { MessageBox.Show("Invalid login Please Check Username And Password"); } conn.Close();
} } } for student
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.SQLite;
namespace Term_Project {
public partial class Student : Form { private int id; private new string name; private string Sname; private string dept;
public Student(int v1, string v2, string v3, string v4) { this.id = v1; this.name = v2; this.Sname = v3; this.dept = v4;
InitializeComponent();
}
private void Student_Load(object sender, EventArgs e) { txtid.Text = id.ToString(); txtName.Text = name; txtSurname.Text = Sname; txtDepartment.Text = dept;
}
}
}
SLogin - n . ID 300 Password Login Student - X ID 300 Name LB Sumame James Department Software Engineering 2 Tablo: Takes S-ID Course-ID Filtre Filtre Course-Name Filtre 1 300 2 300 3 3 300 4 300 1001 Database Management 1002 System Programming 1003 Analysis of Algorithm 1004 Computer Architecture 1001 Database Management 1004 Computer Architecture 1001 Database Management 5 301 6 301 7 302Step by Step Solution
There are 3 Steps involved in it
Step: 1
Get Instant Access to Expert-Tailored Solutions
See step-by-step solutions with expert insights and AI powered tools for academic success
Step: 2
Step: 3
Ace Your Homework with AI
Get the answers you need in no time with our AI-driven, step-by-step assistance
Get Started