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.
我有从mysql到datagrid视图获取所有数据的代码,但我不知道从mysql获取数据到文本框。此文本框具有只读属性,它将显示登录用户的用户名。
For further understanding here is the image.
为了进一步理解,这里是图像。
Here is my code on getting mysql database to datagridview.
这是我的mysql数据库到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.
这是我为姐姐的生意做的个人计划。实际上我的计划是首先显示登录用户示例“Admin123”然后我将数据“Admin123”插入到数据网格视图用户,这是他们登录时的当前用户,所以基本上如果Admin456将登录,那么他的名字将是显示在登录用户文本框和DataGridView中的用户。一种监控登录的不同用户的登录活动。
1 个解决方案
#1
0
From where are you assigning a value to your text box?? (Login User). read the suitable position in your List (detailList) for username and assign it to text box (login user). and if you want to display records belongs to logged user you have to change the query to select * from sales where username=usernameYouHaveGivenInLoginPage.
从哪里为文本框分配值? (登录用户)。读取List(detailList)中用于用户名的合适位置,并将其分配给文本框(登录用户)。如果要显示属于已登录用户的记录,则必须更改查询以选择* from sales where username = usernameYouHaveGivenInLoginPage。
thanx...
#1
0
From where are you assigning a value to your text box?? (Login User). read the suitable position in your List (detailList) for username and assign it to text box (login user). and if you want to display records belongs to logged user you have to change the query to select * from sales where username=usernameYouHaveGivenInLoginPage.
从哪里为文本框分配值? (登录用户)。读取List(detailList)中用于用户名的合适位置,并将其分配给文本框(登录用户)。如果要显示属于已登录用户的记录,则必须更改查询以选择* from sales where username = usernameYouHaveGivenInLoginPage。
thanx...