0

I have codes of getting all the datas from mysql to datagrid view but I am stuck in getting data from mysql to the textbox. This textbox has read only property it is where the username of the login user will be displayed.

For further understanding here is the image.

click image

Here is my code on getting mysql database to datagridview.

private void frmMain_Load(object sender, EventArgs e)
        {
            a = new ApareceCrudLib("localhost", "root", "", "cashieringdb");
            loadDataGridView_Main();
        }
        public void loadDataGridView_Main()
        {
            dgvMain.Rows.Clear();
            List<string>[] detailList = a.mysqlSelect("Select * From sales");
            for (int i = 0; i < detailList.Length; i++)
            {
                dgvMain.Rows.Add(detailList[i][0], detailList[i][1], detailList[i][2], detailList[i][3]);
            }
        }

This is a personal program I do this for the business of my sister. Actually my plan is to display first the Login User example "Admin123" then I will insert the data "Admin123" to Data Grid view user which is the current user at the time they log in so basically if Admin456 will login then his name will be displayed on Login User textbox and User in DataGridView. A sort of monitoring the login activity of different user who login.

4

1 回答 1

0

你从哪里为你的文本框赋值?(登录用户)。在您的列表(detailList)中为用户名读取合适的位置并将其分配给文本框(登录用户)。如果要显示属于已登录用户的记录,则必须将查询更改为从用户名 = 用户名YouHaveGivenInLoginPage 的销售中选择 *。

谢谢...

于 2013-03-30T14:19:45.967 回答