简体   繁体   English

我无法使用 c# 和 MS Access DB 过滤当前用户记录

[英]I connot able to filter the current user record using c# and MS Access DB

I connot able to filter the current user record.我无法过滤当前用户记录。 I want to display the data of current user only.我只想显示当前用户的数据。 But I did not understand how to handl query.但我不明白如何处理查询。 here is the ss of login.这是登录的ss。 在此处输入图像描述

As I selected Student, and username =50 and pass=50,因为我选择了 Student,username =50 和 pass=50,

and when i press he show button this will display all the record but i want only current user data:当我按下显示按钮时,这将显示所有记录,但我只需要当前用户数据: 在此处输入图像描述

here is the code:这是代码:

conn.Open();
                    OleDbCommand cmd = new OleDbCommand();
                    cmd.Connection = conn;
                    OleDbDataAdapter sda = new OleDbDataAdapter(@"SELECT student.s_id, student.f_name, student.l_name, student.email, student.address, course.c_id, course.cname, resultdate.resultgrade FROM ((student INNER JOIN resultdate ON student.s_id = resultdate.s_id) INNER JOIN course ON resultdate.c_id = course.c_id)", conn);
                DataTable dt = new DataTable();
                sda.Fill(dt);
                dataGridView1.DataSource = dt;
                //dataGridView1.Text = dt.Rows.Count.ToString();
                conn.Close();

Paste this code in your combobox.将此代码粘贴到您的 combobox 中。

        con.Open();

        string query = “ select* from student where student.s_id =  ’”
        +combobox1.SelectedItem.ToString() + “’”;
        OleDbDataAdapter sda = new OleDbDataAdapter(query, con);
        OleDbCommandBuiler builer = new OleDbCommandBuiler(da);
        var ds = new DataSet();
        sda.Fill(ds);
        datagridview1.Datasource = ds.Table[0];

        conn.Close();

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM