尝试只返回前几行,因为我的数据库太大了,但是当我测试我的SQL时,我做了一个select *并且只返回了第一行.
SqlCommand sqlCmd = new SqlCommand();
SqlDataReader reader;
sqlCmd.CommandText = "SELECT * FROM Log";
sqlCmd.CommandType = CommandType.Text;
sqlCmd.Connection = myConnection;
myConnection.Open();
reader = sqlCmd.ExecuteReader();
Log logs = null;
while (reader.Read())
{
logs = new Log();
logs.Id = Convert.ToInt32(reader.GetValue(0));
}
return logs;
myConnection.Close();
Run Code Online (Sandbox Code Playgroud)
我的解决方案有什么问题?