public partial class Admin_Control : Form { Form1.User aa; public string sa; private Form1.User ua; public Admin_Control(Form1.User s1) { InitializeComponent(); this.ua = ua; aa = s1; } private void button7_Click(object sender, EventArgs e) { Main mn = new Main(ua); mn.Show(); this.Hide(); } private void dataGridView1_CellContentClick(object sender, DataGridViewCellEventArgs e) { if (e.ColumnIndex == 1) { OleDbConnection con = new OleDbConnection("Provider=Microsoft.ACE.OLEDB.12.0;Data Source=D:\\IT Inventory management\\IT Inventory Database.accdb"); OleDbCommand cmd = con.CreateCommand(); cmd.CommandText = "UPDATE Login SET UserRole ='Admin'"; con.Open(); cmd.ExecuteNonQuery(); MessageBox.Show("User Role Updated"); } else { MessageBox.Show("Changes Failed"); } } private void show() { DataTable dt = new DataTable(); OleDbConnection con = new OleDbConnection("Provider=Microsoft.ACE.OLEDB.12.0;Data Source=D:\\IT Inventory management\\IT Inventory Database.accdb"); OleDbCommand cmd = con.CreateCommand(); cmd.CommandText = "SELECT * FROM Login"; con.Open(); OleDbDataReader adr= cmd.ExecuteReader(); dt.Load(adr); dataGridView1.DataSource = dt; //dataGridView1.DataBind(); DataGridViewButtonColumn btn = new DataGridViewButtonColumn(); btn.HeaderText = "Change User Role"; btn.Name = "btn_change"; btn.Text = "Change"; btn.UseColumnTextForButtonValue = true; dataGridView1.Columns.Add(btn); } private void button1_Click(object sender, EventArgs e) { dataGridView1.Visible = true; show(); } private void uname() { string admi = ""; OleDbConnection con = new OleDbConnection("Provider=Microsoft.ACE.OLEDB.12.0;Data Source=D:\\IT Inventory management\\IT Inventory Database.accdb"); OleDbCommand cmd = con.CreateCommand(); cmd.CommandText = "SELECT UserRole FROM Login WHERE Username='" + sa + "' "; con.Open(); OleDbDataReader adm; adm = cmd.ExecuteReader(); } private void Admin_Control_Load(object sender, EventArgs e) { sa = aa.name; ** lbl_name.Text = aa.name; uname(); } private void button3_Click(object sender, EventArgs e) { New_User nu = new New_User(); nu.Show(); this.Close(); } } }
This is the code and I get Error on the code marked with **
var
This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)