Check for EOF in ADO.NET

Cechoz

New Member
Hi,<BR>In ASP I used to check for EOF by applying:<BR>If Not objRecordSet.EOF Then<BR> ....<BR>End If<BR><BR>How can I do this in ADO.NET using the SqlDataReader ?!<BR><BR>Thank you.<BR><BR>MazenI hope this example helps:<BR><BR><%@ Page Language="VB" %><BR><%@ Import Namespace="System.Data" %><BR><%@ Import Namespace="System.Data.SqlClient" %><BR><%<BR>Dim strConnection As SqlConnection<BR>Dim cmdSelectEmployees As SqlCommand<BR>Dim dtrEmployees As SqlDataReader<BR><BR>strConnection = New SqlConnection("server=localhost; database=Northwind; uid=sa; pwd=password;")<BR>strConnection.Open()<BR><BR>cmdSelectEmployees = New SqlCommand("SELECT LastName FROM Employees", strConnection)<BR>dtrEmployees = cmdSelectEmployees.ExecuteReader()<BR>While dtrEmployees.Read()<BR> Response.Write("<li>")<BR> Response.Write(dtrEmployees("LastName"))<BR>End While<BR>dtrEmployees.Close()<BR>strConnection.Close()<BR>%>
 
Back
Top