First time I am posting, so please forgive me if I miss out any information while asking you my question. I have a .net web app that I am building in 2.0 framework. I have a code-behind file that calls a method in a business logic class. The method in the class talks to the database through a database access layer. Through the database access layer I create a tableadapter through SPs in the database. I need to return a datatable to the code-behind class for the front layer. However I do not know how to handle returning an empty datatable in case I encounter that.
thanks much in advance
<System.ComponentModel.DataObjectMethodAttribute(System.ComponentModel.DataObjectMethodType.Select, False)> _ Public Function MenuControl(ByVal Username As String, ByVal Password As String) As EFAST.tbl_UsersDataTable ' Create a new datatable instance for the dataset from the getdataby method Dim datatableUserLogin As EFAST.tbl_UsersDataTable = Adapter.GetDataByUsername(Username) If datatableUserLogin.Count = 0 Then ' no matching record found, return 0 this is where I have the problem Return Nothing End If Dim datarowUserLogin As EFAST.tbl_UsersRow = datatableUserLogin(0) If some business logic Then ' matching record found, return userid Return datatableUserLogin End If End Function