hello , i created database using MS access contain Admin table{adminID, usertype, username, userpassword} and staff table {staffID, password ....etc}, i want to create login form in C# if the user is admin can login and can add staff's ID and put a password for them... also the staff can login by their ID and their own password. please help i'm getting errors
using System; using System.Collections.Generic; using System.ComponentModel; using System.Data; using System.Data.OleDb; using System.Data.Odbc; using System.Drawing; using System.Linq; using System.Text; using System.Windows.Forms; namespace eee1 { public partial class Form1 : Form { public Form1() { InitializeComponent(); } private void Button2_Click_1(object sender, EventArgs e) { this.Close(); } private void Form1_Load(object sender, EventArgs e) { } private void btnlogin_Click(object sender, EventArgs e) { OleDbConnection connection = new OleDbConnection(); connection.ConnectionString =@"Provider=Microsoft.Jet.OLEDB.4.0;Data Source=C:\Users\sss\Documents\Visual Studio 2010\Projects\eee1\eee1\EMP.accdb;adminId=admin;"; connection.Open(); OleDbCommand command = new OleDbCommand("SELECT * FROM Admin", connection); OleDbDataReader reader = command.ExecuteReader(); try { while (reader.Read()) { txtuname.ToString(); txtupass.ToString(); if (txtuname.Text =="admin" &&txtupass.Text =="admin") { this.Hide(); new MainForm().Show(); break; } else MessageBox.Show("UserName/Password doesnt exist"); break; } } catch (Exception err) { MessageBox.Show(err.Message); } finally { connection.Close(); command.Dispose(); connection.Dispose(); } } } }