which way is better?

S

Scott Reynolds

Hello!

I developed a web application to display results from the database. Now I
need to add search function, to search, sort and filter data.

My question is, which way is better...

1) Store all related data in a single DataSet and use DataView to filter and
sort data

OR

2) Join related data to a single results set and filter data on the database
side, then store already filtered data in DataSet.

Database structure:

Table "Users" (parent) ~ 5000 records
Table "Orders" (child)
Table "Payments" (child)

I am using MS Access database.

All suggestions are welcome!

Scott
 
M

Miha Markic [MVP C#]

Hi Scott,

It depends on your needs. I would suggest method 2) if you don't need to
store data back into database and vice versa.
 
S

Scott Reynolds

Hello Miha,

Thank you for good suggestions.

Although the next question is off this topic, but maybe you could help me
little more...?

Lets say that I would like to display all Sellers who have at least 3
products.... then I must use DataRowView.CreateChildView or I can achieve
it?

I am using code below to fill DataSet and create Relations:
.....
myDA = New OleDbDataAdapter("select * from Users", myConn)
myDA .Fill(myDS, "Users")

myDA = New OleDbDataAdapter("select * from Payments", myConn)
myDA .Fill(myDS, "Payments")

myDA = New OleDbDataAdapter("select * from Orders", myConn)
myDA .Fill(myDS, "Orders")

myDS.Relations.Add("Users_PaymentsREL", _
myDS.Tables("Users").Columns("Id"), _
myDS.Tables("Payments").Columns("UsersId"), False)

myDS.Relations.Add("Users_OrdersREL", _
myDS.Tables("Users").Columns("Id"), _
myDS.Tables("Orders").Columns("UsersId"), False)

UsersDV = NewBuildDS.Tables("Users").DefaultView

myDataGrid.DataSource = UsersDV
myDataGrid.DataBind()

Regards,
Scott
 
M

Miha Markic [MVP C#]

I suggest you to create a strong typed dataset (so you won't need all that
code) and fill in only selected records (put the "3 records" limit into
select statements).
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Top