Answered step by step
Verified Expert Solution
Link Copied!

Question

1 Approved Answer

I log in to the student login with the data I get from the database, but I want the information to come automatically with the

I log in to the student login with the data I get from the database, but I want the information to come automatically with the student ID and password I entered in the newly opened form.

Here's the c# code I wrote, what should I add so that it comes automatically?

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\\B\\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(); std.Show(); this.Hide();

} else { MessageBox.Show("Invalid login Please Check Username And Password"); } conn.Close(); } } } image text in transcribed

ID Name Surname Filtre Filtre Filtre 1 300 LB James Dept_Name Password Filtre Filtre Computer Engineering 300 11 SLogin ID 300 2 Password Login Student - 0 ID IN Name 3 Sumame Department

Step by Step Solution

There are 3 Steps involved in it

Step: 1

blur-text-image

Get Instant Access to Expert-Tailored Solutions

See step-by-step solutions with expert insights and AI powered tools for academic success

Step: 2

blur-text-image

Step: 3

blur-text-image

Ace Your Homework with AI

Get the answers you need in no time with our AI-driven, step-by-step assistance

Get Started

Students also viewed these Databases questions