FROM子句中的语法错误C#& MS-访问

时间:2017-12-06 10:50:13

标签: c# ms-access

我很容易从MS Acces数据库中获取信息并将其放在一些文本框中,但是我收到了错误

  

FROM子句中的语法错误

我不知道我做错了什么,而且sql在Access本身也适用。

        try
        {
            conn.Open();
            cmd.Connection = conn;
            cmd.CommandText = @"SELECT [CharacterID], [CharacterName], [Race], [Class], [Background], [Level], [Alignment], [Experience Points], [PlayerName]
                                FROM Character";

            reader = cmd.ExecuteReader();

            Player p = new Player();

            while (reader.Read())
            {
                p.CharacterID = reader.GetInt32(0);
                p.CharacterName = reader.GetString(1);
                p.Race = reader.GetString(2);
                p.Class = reader.GetString(3);
                p.Background = reader.GetString(4);
                p.Level = reader.GetInt32(5);
                p.Alignment = reader.GetString(6);
                p.ExperiencePoints = reader.GetInt32(7);
                p.PlayerName = reader.GetString(8);
            }
            characters.Add(p);

            txtCharacterName.Text = p.CharacterName;
            txtClassLevel.Text = p.Class + " " + p.Level.ToString();
            txtBackground.Text = p.Background;
            txtPlayerName.Text = p.PlayerName;
            txtRace.Text = p.Race;
            txtAlignment.Text = p.Alignment;
            txtExperiencePoints.Text = p.ExperiencePoints.ToString();
        }

        catch (Exception ex)
        {
            MessageBox.Show(ex.Message);
        }
    }

0 个答案:

没有答案