C# 从数据库填充datagridview
我试图从数据库(cassandra)填充datagridview,但由于某些原因,它只显示一行而不是两行,您能告诉我我做错了什么吗C# 从数据库填充datagridview,c#,database,datagridview,cassandra,C#,Database,Datagridview,Cassandra,我试图从数据库(cassandra)填充datagridview,但由于某些原因,它只显示一行而不是两行,您能告诉我我做错了什么吗 public void show_db() { var cluster = Cluster.Builder().AddContactPoint("127.0.0.1").Build(); var session = cluster.Connect("hotel");
public void show_db()
{
var cluster = Cluster.Builder().AddContactPoint("127.0.0.1").Build();
var session = cluster.Connect("hotel");
RowSet rs = session.Execute("SELECT * FROM hotel.staff");
foreach (var res in rs)
{
for (int i = 0; 2 < 3; i++)
{
for (int j = 0; j < 4; j++)
{
staff_info.Rows[i].Cells[j].Value = res.GetValue<string>("staff_id");
staff_info.Rows[i].Cells[j].Value = res.GetValue<string>("username");
staff_info.Rows[i].Cells[j].Value = res.GetValue<string>("password");
staff_info.Rows[i].Cells[j].Value = res.GetValue<string>("name");
}
}
}
}
public void show_db()
{
var cluster=cluster.Builder().AddContactPoint(“127.0.0.1”).Build();
var会话=cluster.Connect(“酒店”);
行集rs=session.Execute(“SELECT*fromhotel.staff”);
foreach(以卢比表示的var res)
{
对于(int i=0;2<3;i++)
{
对于(int j=0;j<4;j++)
{
staff_info.Rows[i].Cells[j].Value=res.GetValue(“staff_id”);
staff_info.Rows[i].Cells[j].Value=res.GetValue(“用户名”);
staff_info.Rows[i].Cells[j].Value=res.GetValue(“密码”);
staff_info.Rows[i].Cells[j].Value=res.GetValue(“名称”);
}
}
}
}
我想为一个愚蠢的问题道歉……这不可能是您的实际代码,您有一个无限循环。