问题描述
privateSqlDataAdapterGetStaffs(){StringcmdText="SELECTTOP5Staff_NameFROMStaffORDERBYStaff_IDDESC";SqlConnectionmyConnection=newSqlConnection(SQLCONNECTIONSTRING);SqlCommandmyCommand=newSqlCommand(cmdText,myConnection);myConnection.Open();SqlDataReaderdr=myCommand.ExecuteReader(CommandBehavior.CloseConnection);return(dr);}调试时显示:“Sysemt.Data.SqlClient.SqlDataAdapter”并不包含“Read”的定义;“Sysemt.Data.SqlClient.SqlDataAdapter”并不包含“Close”的定义请问如何解决?
解决方案
解决方案二:
privateSqlDataReaderGetStaffs()
解决方案三:
SqlCommandmyCommand=newSqlCommand(cmdText,myConnection);SqlDataReaderdr=myCommand.ExecuteReader();returndr;
时间: 2024-09-20 15:28:34