Using C#, asp.net 3.5, SqlServer 2005,
Trying to incorporate some inversion of control together with 3-tier architecture into my current assignment.
Don’t know enough to know if this is a great idea or an incredibly dumb one:
I have created a User Interface Layer, a Business Layer, and a Data Layer.
The UI collects 4 values, News an instance of a Business Layer class (call it c) , initializing it with the 4 values.
The UI then calls a method of that instance of the Business Layer class to save the data.
The Business Layer class method creates a tsql string such as
String.Format (@”insert into table1 ( col1, ‘col2’, ‘col3’, col4) values ({0}, {1}, {2}, {3}); select @@identity”, c.one, c.date1, c.date2, c.four) ;
and passes the string to a int method of a class in the Data Layer.
the Data Layer uses the string as the CommandText of an ExecuteScalar and returns the @@identity to the Business Layer.
I would use a variation of the same concept to retrieve data through a datareader.
The amount of data is not going to be large and this isn't going to be a high volume application.
The way I have done this in the past was to pass the 4 values collected in the ui, through the Business Layer to the Data Layer set up sqlparms, pass the values to a stored procedure, etc, pass them back to the business layer, etc.