|
-
May 24th, 2007, 03:43 PM
#1
Thread Starter
Hyperactive Member
[RESOLVED] Data Sets - Databases
Alright I have a project where I load a database table into a DataSet and DataAdapter using SQLClient.SqlConnection. I am using this to create reports and I am trying to add dynamic filters to the report ( Only view certain items, select by name, things like that ). Now, currently I have to use a whole new query and grab that from the database every time I change the output specifications. Is there a way I can skip going through the database and just Query the original DataSet that I have created ?
Code:
Dim oConn As SqlClient.SqlConnection = New SqlClient.SqlConnection(cString)
Dim tAdap As SqlClient.SqlDataAdapter
Dim sQuery As String = "SELECT * FROM ReportView"
Dim dSet As DataSet
' Code in here that adds to the query when specific items are selected
' ex. WHERE fieldA = 1 AND name = 'Nick'
tAdap = New SqlClient.SqlDataAdapter(sQuery, oConn)
dSet = New DataSet()
tAdap.Fill(dSet, table)
' Using the DevExpress Framework (.repx is a report file)
rep = XtraReport.FromFile("reportView.repx", True)
rep.DataSource = dSet
rep.DataAdapter = tAdap
rep.DataMember = table
Thanks for your help..
-
May 24th, 2007, 04:08 PM
#2
Lively Member
Re: Data Sets - Databases
Have you tried filtering the defaultview of the dataset? Not sure if reports look at this but I know most controls do.
dSet.Tables(0).DefaultView.RowFilter = "(fieldA = 1) AND (name = 'Nick')"
-
May 25th, 2007, 07:33 AM
#3
Thread Starter
Hyperactive Member
Re: Data Sets - Databases
Thank you for that, that helps a lot with the views...
Now is there any way to do that with the sort order ? asc ? desc ?
thanks.
-
May 25th, 2007, 08:42 AM
#4
New Member
Re: Data Sets - Databases
yes, in a similar fashion to filtering the data it can be sorted with the RowFilter property of the datatable.
Code:
'sort ascending
dSet.Tables(0).DefaultView.RowFilter = "MyColumnName ASC"
'sort descending
dSet.Tables(0).DefaultView.RowFilter = "MyColumnName DESC"
-
May 25th, 2007, 09:31 AM
#5
Thread Starter
Hyperactive Member
Re: Data Sets - Databases
-
May 25th, 2007, 11:20 AM
#6
Thread Starter
Hyperactive Member
Re: Data Sets - Databases
 Originally Posted by TirRaven
yes, in a similar fashion to filtering the data it can be sorted with the RowFilter property of the datatable.
Code:
'sort ascending
dSet.Tables(0).DefaultView.RowFilter = "MyColumnName ASC"
'sort descending
dSet.Tables(0).DefaultView.RowFilter = "MyColumnName DESC"
Just for Reference:
Code:
'sort Ascending
dSet.Tables(0).DefaultView.Sort = "MyColumnName ASC"
'sort Descending
dSet.Tables(0).DefaultView.Sort = "MyColumnName DESC"
Use the Sort function instead of the Row Filter for sorting by columns.
-NP
-
May 25th, 2007, 11:52 AM
#7
New Member
Re: Data Sets - Databases
 Originally Posted by NPassero
Use the Sort function instead of the Row Filter for sorting by columns.
-NP
oops haha, yea thats what i ment to post...
Posting Permissions
- You may not post new threads
- You may not post replies
- You may not post attachments
- You may not edit your posts
-
Forum Rules
|
Click Here to Expand Forum to Full Width
|