| | |
Returning Empty Datatable
Please support our ASP.NET advertiser: Intel Parallel Studio Home
![]() |
•
•
Join Date: Dec 2006
Posts: 2
Reputation:
Solved Threads: 0
Hi All,
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
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
Last edited by rgambhir; Dec 13th, 2006 at 1:23 am.
•
•
Join Date: Mar 2006
Posts: 84
Reputation:
Solved Threads: 1
dude i didnt understand u well.
but i will assume that u r asking how to return empty datatable.
i dont remember i did that since i always use dataset. in my case i return ds without testing and in the code behind i make the login test according to
if (ds.tables(0).rows.count<> 0) then
...
else
..
end if
i hope that answers ur question
sam
but i will assume that u r asking how to return empty datatable.
i dont remember i did that since i always use dataset. in my case i return ds without testing and in the code behind i make the login test according to
if (ds.tables(0).rows.count<> 0) then
...
else
..
end if
i hope that answers ur question
sam
•
•
Join Date: Dec 2006
Posts: 2
Reputation:
Solved Threads: 0
•
•
•
•
dude i didnt understand u well.
but i will assume that u r asking how to return empty datatable.
i dont remember i did that since i always use dataset. in my case i return ds without testing and in the code behind i make the login test according to
if (ds.tables(0).rows.count<> 0) then
...
else
..
end if
i hope that answers ur question
sam
thanks
-Raj
•
•
Join Date: Mar 2006
Posts: 84
Reputation:
Solved Threads: 1
ok dude
what i did is i have a function return dataset (ds) inside a data access layer.
now in the code behind as i write above i make the login condition for the number of the rows in the table number 0 inside in the ds.
if (ds.tables(0).rows.count<> 0) then
not empty ds
else
empty ds
end if
if the rows greater than 0 then the ds isnt empty else its empty.
i dont use try and catch.
sam
what i did is i have a function return dataset (ds) inside a data access layer.
now in the code behind as i write above i make the login condition for the number of the rows in the table number 0 inside in the ds.
if (ds.tables(0).rows.count<> 0) then
not empty ds
else
empty ds
end if
if the rows greater than 0 then the ds isnt empty else its empty.
i dont use try and catch.
sam
![]() |
Similar Threads
- check if datatable is empty (VB.NET)
- Getting "DB_E_ERRORSINCOMMAND" even when execute is successful (C)
- IListSource does not contain any data sources (ASP.NET)
- Please help me with arrays (C++)
Other Threads in the ASP.NET Forum
- Previous Thread: asp.net error iss killing me
- Next Thread: Opening a .pdf file at the clientside without the open/save dialog box
| Thread Tools | Search this Thread |
.net activexcontrol advice ajax alltypeofvideos appliances asp asp.net bc30451 beginner bottomasp.net box browser button c# cac checkbox click commonfunctions control css dataaccesslayer database datagridview datagridviewcheckbox datalist deadlock deployment development dgv dialog dropdownlist dynamic dynamically edit embeddingactivexcontrol expose fileuploader fill findcontrol flash formatdecimal formview gridview gudi iframe iis javascript listbox login microsoft mono mouse mssql multistepregistration news novell numerical objects opera panelmasterpagebuttoncontrols radio redirect registration relationaldatabases reportemail rotatepage save schoolproject search security sessionvariables silverlight smartcard smoobjects software sql-server sqlserver2005 ssl suse textbox tracking treeview unauthorized validatedate validation vb.net video videos virtualdirectory vista visualstudio web webapplications webdevelopemnt webdevelopment webprogramming webservice xsl youareanotmemberofthedebuggerusers





