tags:

views:

66

answers:

2

Using VB.Net and C#.Net

Using 3 Tier, I was executing this query in DataAccessLayer, i want to call this query in ApplicationLayer throgh BUsinessLogicLayer.

Code.

Cmd = New SqlCommand("Exec delTable", con)
cmd.ExecuteNonQuery

I want to return this execute command like this,

In application Layer How to call this?

Can anyone Provide a sample code.

+3  A: 

Shouldn't you be treating TIERs with the same respect you'd treat any layered architecture? (i.e. You have layers to allow each to ONLY speak nicely to its neighbors and "reaching" directly between is not good programming.)

You should wrap these data layer calls. The whole point would be that if you ever needed to alter the data calls you do NOT have to go searching all your source... you go to ONE PLACE.

just my 2 cents.

tob

tobrien
+1  A: 

It would be better to pass Data around!

Dim customers = myCustomerDataAccess.GetAll()

I am not sure if I get your question (and architectural issues beside), you can just return the SqlCommand itself and call the "execute" later (But just don't do that!).

Sub Main
    GetSomeSpecificCommand().ExecuteNonQuery()
End Sub

Public Function GetSomeSpecificCommand() as SqlCommand
    Dim cmd = New SqlCommand("Exec delTable", new SqlConnection())
    Return cmd
End Function 

You could write you own wrapper for SqlCommand.

Robert