Click to See Complete Forum and Search --> : How to access data through the objectdatasource in ASP.NET 2.0 code behind?


edustreet
12-12-2008, 03:59 AM
Hi,

I have create number of Dataset which in App_code. I know how to use the table adapter to connect database and command in design page. But I need to get the data from dataset in codebehind.

This is a real example I need to solve:

In my database table, I need to access three column of data to analyze it and get the output I want. For example, the column1 is phone1, column2 is phone2 and column3 is phone3. So in my sql query, I do like this

sql = "Select phone1, phone2, phone3 from mytable"

Because I need to get this 3 column of data to put in my logic to get the output I want. Once the logic decide which column to use, then another logic will filtering the data and get the final out. For example, once decide to use column1 data, the data contain a long string, But I just need some of the character/string only.

My problem is, how can I use the dataset which store in app_code to access the data and put in my logic.

In asp.net 1.1, I can do like this :

Dim ds as dataset
.
.
.
Dim getData As String = ds.Tables(0).Rows(s).Item("Phone1")

If getData = ... Then
....
End If

In asp.net 2.0
?

Any solution and references are appreciated.

Calvin

Termite
12-13-2008, 07:23 PM
www.asp.net has some really good tutorials on best practices for using data access and business logic layers. I would recommend running through these tutorials at http://www.asp.net/learn/data-access/ - the introduction section runs through setting up data access and business logic layers.

edustreet
12-14-2008, 08:29 PM
Thanks for your reference. Hope I can get solution from it. By the way thank you very much.

More suggestion and reference are welcome. :)