数据库的连接,照书上的代码写的,没法显示前两行,一直显示‘关键字Table’附近有语法错误

图片说明图片说明

using System;
using System.Collections.Generic;
using System.Data;
using System.Data.SqlClient;
using System.Diagnostics;
using System.Linq;
using System.Text;
using System.Threading.Tasks;

namespace A006
{
public class ExecuteNonQueryExample
{
public static void Main()
{
string str = "Data Source=(local);Initial Catalog=Student1;Integrated Security=True;Pooling=False";
SqlConnection conn = new SqlConnection(str);
string SQLstr = "select top 1 * from Table";
SqlCommand comm = new SqlCommand(SQLstr, conn);
SqlDataReader rd;
try
{
conn.Open();
rd = comm.ExecuteReader();
while (rd.Read())
{
Console.WriteLine("{0}\t{1}\t{2}\t{3}\t{4}\t{5}", rd["StudentID"].ToString(), rd["XueHao"], rd[2], rd[3], rd[4], rd[5]);
}
}
catch(Exception ex)
{
Console.WriteLine(ex.Message);
}
finally
{
conn.Close();
}
}
}
}

select * from [table]

select * from table

table 是个代称, 指你当前连接的数据库中, 某个表的名字, 你需要替换掉

报错是你当前连接的数据库中, 没有一个名字是 table 的表

table是关键字吧