没有给出所需参数的值

时间:2015-03-23 20:56:01

标签: visual-studio-2012 visual-studio-2013 ms-access-2013

ACCESS 2013数据库,我有2个表1用于用户,表2用于书籍我想要显示用户1已经拍摄的所有书籍并且已经这样做了我想问为什么在visual studio中查询有错误它在MS-ACCESS 2013查询构建器中正常工作,数据库在此链接中,你将找到查询结果图像并显示参数我不需要的任何值我认为我做了所有gd。

Database link

OleDbConnection connection = new OleDbConnection(@"");
        OleDbCommand command = connection.CreateCommand();
        OleDbDataReader reader;
        try
        {

            string R = "SELECT * FROM Table1 INNER JOIN Table2 ON Table1.ID = Table2.Relation WHERE Table1.ID = 1";
            command.CommandText = R;
            connection.Open();
            reader = command.ExecuteReader();
            if (reader.HasRows)
            {
                while (reader.Read())
                {
                    ID1.Text = reader["Table1.ID"].ToString();
                    fName.Text = reader["FirstName"].ToString();
                    lName.Text = reader["LastName"].ToString();
                    ID2.Text = reader["Table2.ID"].ToString();
                    book.Text = reader["Book"].ToString();
                }
            }
            reader.Close();
            connection.Close();

        }
        catch (Exception x)
        {
            connection.Close();
            MessageBox.Show(x.Message.ToString());
        }
        finally
        {
            connection.Close();
        }

0 个答案:

没有答案