Hi
Yes you can do it with
DataReader
object:
Public Function ExecuteQuery(ByVal SQL As String) As DataSet
Dim dr As New SqlDataReader ' or OleDataReader
Dim List<object> myReaderList = new List<object>()
Try
If SQLConn.State = ConnectionState.Open Then SQLConn.Close()
Dim SQLCmd As New SqlCommand
ConnectionState.Open
SQLCmd.Connection = SQLConn
SQLCmd.CommandText = SQL
dr = SQLCmd.ExecuteReader()
while(dr.Read())
myReaderList.Add(dr.Read("FiealName"))
end while
SQLCmd.Connection.Close()
' you can remove SQLAdp and dt maybe you don`t need that ;)
Dim SQLAdp As New SqlDataAdapter(SQLCmd)
SQLAdp.Fill(dt)
Catch ex As Exception
dt = Nothing
End Try
Return dt
End Function</object></object>
Of course you should note if you are close the
connection
you will lost
reader
so close
connection
after finished your work with
reader
.
Best Regards.