StrataFrame Forum

Datareader equivalent...

http://forum.strataframe.net/Topic3415.aspx

By StarkMike - 10/9/2006

Here is some of my code using a datareader... what is the strataframe equivalent to a datareader?





Using conn As New SqlConnection(ConnectionString)

Dim cmd As New SqlCommand



cmd.CommandText = StoredProcedureName

cmd.CommandType = CommandType.StoredProcedure

cmd.Connection = conn



cmd.Parameters.AddRange(params)

conn.Open()



Dim reader As SqlDataReader = cmd.ExecuteReader()



While reader.Read

msLocationName = reader("LocationName")

miLocationID = reader("LocationID")



End While



reader.Close()

reader = Nothing

conn.Close()

End Using





Thanks
By StrataFrame Team - 10/10/2006

Everything in StrataFrame is disconnected data, but ADO.NET has a DataTableReader that operates in the same fashion as the DbDataReader (by implementing the IDataReader interface).  So, if you wanted to create a "reader" you would do this (from within a business object):

Public Function GetReader() As DbDataReader
    '-- Execute the statement and return a new reader
    Return New DataTableReader(Me.GetDataTable("SELECT TOP 100 * FROM Customers"))
End Function

By StarkMike - 10/12/2006

Hey Ben,



Based on the code you provided in your last post I put this piece of code together



 Dim dtbl As DataTable = DataBasics.DataSources("").GetDataTable(cmd, Nothing) 




Which works and does what i want it to... the only question I have is what am i supposed to provide for the ByVal CallBack As System.Data.SqlClient.OnChangeEventHandler argument? I put Nothing and it works I'm just not sure if thats what I'm supposed to put there. Hehe
By Trent L. Taylor - 10/12/2006

Nothing will work fine if you do not want to execute this asynchronously and invoke a callback method when it is completed.  By providing the nothing it will just block until the method has completed executing.
By StrataFrame Team - 10/12/2006

That method will always block... the callback is used for you to provide a method that should be called if you are using Query Notification Services and the server raises the DataChanged event.  If you're not using QNS (which you probably aren't) then just pass in Nothing every time.
By StarkMike - 10/12/2006

Thanks Guys! BigGrin