C# c窗体应用程序游戏

C# c窗体应用程序游戏,c#,C#,我需要做一个从a点到b点的移动物体游戏。 我通过一个包含x和y列的表连接到一个数据库。 我在数据表中有sql数据库,但我不知道如何将行移到picturebox的位置 这是我的密码。这就是我的全部: MySqlConnection conn = new MySqlConnection("Server=localhost;Database=programeren;Uid=root;Pwd=;"); conn.Open(); MySql

我需要做一个从a点到b点的移动物体游戏。 我通过一个包含x和y列的表连接到一个数据库。 我在数据表中有sql数据库,但我不知道如何将行移到picturebox的位置

这是我的密码。这就是我的全部:

        MySqlConnection conn =
        new MySqlConnection("Server=localhost;Database=programeren;Uid=root;Pwd=;");

        conn.Open();
        MySqlCommand command = conn.CreateCommand();
        command.CommandText = "select * from vrachtwagen1";
        MySqlDataReader reader = command.ExecuteReader();
        DataTable dtData = new DataTable();
        dtData.Load(reader);
        conn.Close();

这假设表中的列名为“x”和“y”,并且只有一行数据。如果有更多的行,则需要缩小查询范围以返回一行。

是否询问如何遍历数据表?如果您需要vrachtwagen1中的特定行,那么您需要告诉我们表结构和列名。我需要从数据库中获取x和y坐标以移动picturebox。表名结构是一个x和y列,其中只有整数
int x;
int y;

DataTable dtData = new DataTable();
dtData.Load(reader);
if (dt.Rows.Count > 0)
{
    x = dt.Rows[0]["x"];
    y = dt.Rows[0]["y"];
}