Camillia
asked on
Passing data from Buisness Layer to UI Layer
1. I used this code for my Data Access Layer, except that I changed it to VB.Net:
http://aspalliance.com/837_Implementing_a_Data_Access_Layer_in_C
2.--- To test the DAL code in that site, I created a Business Layer and have this in BAL:
Public Class Class1
Public Function test() As String
Dim tt As String
Dim dbManager As IDBManager = New DBManager(DataProvider.Sql Server)
dbManager.ConnectionString = ConfigurationManager.Conne ctionStrin gs("Connec tionString ").Connect ionString. ToString
Try
dbManager.Open()
dbManager.ExecuteReader(Co mmandType. StoredProc edure, "QExample")
While (dbManager.DataReader.Read )
'System.Web.HttpContext.Cu rrent.Resp onse.Write (dbManager .DataReade r("MCode") .ToString( ))
tt = dbManager.DataReader("MCod e").ToStri ng()
End While
Catch ex As Exception
System.Web.HttpContext.Cur rent.Respo nse.Write( "Exception : " + ex.Message.ToString())
Finally
dbManager.CloseReader()
End Try
Return tt
End Function
End Class
3. Then in my UI layer I have this:
Protected Sub Page_Load(ByVal sender As Object, ByVal e As System.EventArgs) Handles Me.Load
Dim test1 As New My_BLL.Class1
Dim value As String
value = test1.test
Response.Write(value)
End Sub
----- That only gets the last value of what the datareader read. How can I pass the entire datareader values from BAL to UI? I know I have defined the Functions's return value as String instead of a datareader....i want to keep the layers separate...I dont want UI to call the dbManager directly..
thanks for any input.
http://aspalliance.com/837_Implementing_a_Data_Access_Layer_in_C
2.--- To test the DAL code in that site, I created a Business Layer and have this in BAL:
Public Class Class1
Public Function test() As String
Dim tt As String
Dim dbManager As IDBManager = New DBManager(DataProvider.Sql
dbManager.ConnectionString
Try
dbManager.Open()
dbManager.ExecuteReader(Co
While (dbManager.DataReader.Read
'System.Web.HttpContext.Cu
tt = dbManager.DataReader("MCod
End While
Catch ex As Exception
System.Web.HttpContext.Cur
Finally
dbManager.CloseReader()
End Try
Return tt
End Function
End Class
3. Then in my UI layer I have this:
Protected Sub Page_Load(ByVal sender As Object, ByVal e As System.EventArgs) Handles Me.Load
Dim test1 As New My_BLL.Class1
Dim value As String
value = test1.test
Response.Write(value)
End Sub
----- That only gets the last value of what the datareader read. How can I pass the entire datareader values from BAL to UI? I know I have defined the Functions's return value as String instead of a datareader....i want to keep the layers separate...I dont want UI to call the dbManager directly..
thanks for any input.
ASKER CERTIFIED SOLUTION
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.