I am a newborn programmer who is currently looking into the Insert, Update and Delete functions in ASP.NET C#. Now I got a little support from a friend who was friendly enough to write a DataAccess for me (I guess it’s a BLL) before he left for work.
I am used to using Datasets and gridviews which is all pretty straight forward, so this way of working with data is very very difficult to me.
Now, I have lots of codes in the DataAccess, but I guess this is the one I have to concentrate about:
/// <summary>
/// Used for Create/Update/Delete etc.
/// </summary>
public void Execute(string query)
{
SqlCommand comm = GetSqlCommand(query);
_conn.Open();
comm.ExecuteNonQuery();
_conn.Close();
}
And I am wondering:
- How do I use an Insert, Update And Delete from a DataAccess file
- What am I supposed to put into my .aspx page?
I hope my questions isn’t too “large” an area to explain if you know what I mean 🙂
Any help is more than appreciated guys!
Regards,
Mike
aaa hi mike,lets review on n-tier architecture :
DB <-> DAL <-> BLL <-> PL
the sample code you write in your question is one part of DAL layer, not BLL layer
about first question :
it depend on your architecture . if you have 3-tier approach , so in your aspx file just write something like this :
but if you have 4-tier approach ,so you just put this(last mentioned code) code in your BLL classes and in your aspx file call a method from BLL classes.
but i have another offer for you my friend , use newer technique such as LinQ or Entity Framework to create your DLL layer and then create a BLL layer.
if you need more help comment me to edit my reply or post another answer for more details.
thanks , Ali