Assume I have a form that has say 5 text boxes and I need to pull some data from a database then set those 5 text boxes with that data.
So assume I have 3 basic layers:
the code behind for a default.aspx page
a BLL class that contacts the DAL
and a data access layer (DAL)
But I've heard and read that the default.aspx page should not know about sqldatareader, in fact you probably dont want to add the sqlclient namesspace to the default.aspx code behind page.
So I used to do something like this:
protected sub DisplayCustomerData()
Dim s as SqlDataReader
Dim b as BLL
b=new BLL();
s = b.GetCustomerData();
//then take s and simply set each text field
if s.read()
TextBox1.Value = s("MyField1")
end if
end sub
Then the BLL would simply call the DAL to call a stored procedure in SQL Server and do a CommandObject.ExecuteReader, get the results pass it back to BLL and BLL would then send it to the code behind page of default.aspx.
I can provide full source code if that doesn't make sense. My question is if its bad that default.aspx actually declares and knows about an SQL Data Reader then what is the better way to do this? What datatype should I be using to avoid having an sqldatareader in my interface code ?