PC Review


Reply
Thread Tools Rate Thread

Applying Filter

 
 
Timo
Guest
Posts: n/a
 
      30th Jun 2005
I have to build dozens of simple data-entry forms in just a couple of days,
and while I'm looking for a 3rd party tool that will help me do this, I
tried the Data Form Wizard in Visual Studio, which builds a persistent
dataset object based on a chosen table or view, and produces some basic
code-behind. The generated routine listed below binds the dataset member
(here, the VISITOR table) to a grid on the form.

How and where can I modify this code to apply a filter to the VISITOR table,
e.g. all visitors whose lastname begins with the letter 'J', so that only
the J-names are shown in the grid?
Thanks
Timo

'// generated by the Data Form wizard
Public Sub LoadDataSet()

Dim objDataSetTemp As FormsWizardTest.dsvisitors
objDataSetTemp = New FormsWizardTest.dsvisitors
Try

Me.FillDataSet(objDataSetTemp)


Catch eFillDataSet As System.Exception
Throw eFillDataSet
End Try


Try
grdVISITOR.DataSource = Nothing

objdsvisitors.Clear()

objdsvisitors.Merge(objDataSetTemp)
grdVISITOR.SetDataBinding(objdsvisitors, "VISITOR")

grdVISITOR.

Catch eLoadMerge As System.Exception

Throw eLoadMerge
End Try

End Sub



 
Reply With Quote
 
 
 
 
=?Utf-8?B?RWx0b24gVw==?=
Guest
Posts: n/a
 
      30th Jun 2005
Hi Timo,

If you want to apply the filter to DB query, sql query is like

SELECT * FROM VISITOR WHERE lastname LIKE ‘J%’

If you get whole data into a datatable then apply the filter, you can use
following code:

Dim dv As DataView = datatable.DefaultView
dv.RowFilter = “lastname LIKE ‘J%’”

HTH

Elton Wang
(E-Mail Removed)

"Timo" wrote:

> I have to build dozens of simple data-entry forms in just a couple of days,
> and while I'm looking for a 3rd party tool that will help me do this, I
> tried the Data Form Wizard in Visual Studio, which builds a persistent
> dataset object based on a chosen table or view, and produces some basic
> code-behind. The generated routine listed below binds the dataset member
> (here, the VISITOR table) to a grid on the form.
>
> How and where can I modify this code to apply a filter to the VISITOR table,
> e.g. all visitors whose lastname begins with the letter 'J', so that only
> the J-names are shown in the grid?
> Thanks
> Timo
>
> '// generated by the Data Form wizard
> Public Sub LoadDataSet()
>
> Dim objDataSetTemp As FormsWizardTest.dsvisitors
> objDataSetTemp = New FormsWizardTest.dsvisitors
> Try
>
> Me.FillDataSet(objDataSetTemp)
>
>
> Catch eFillDataSet As System.Exception
> Throw eFillDataSet
> End Try
>
>
> Try
> grdVISITOR.DataSource = Nothing
>
> objdsvisitors.Clear()
>
> objdsvisitors.Merge(objDataSetTemp)
> grdVISITOR.SetDataBinding(objdsvisitors, "VISITOR")
>
> grdVISITOR.
>
> Catch eLoadMerge As System.Exception
>
> Throw eLoadMerge
> End Try
>
> End Sub
>
>
>
>

 
Reply With Quote
 
Timo
Guest
Posts: n/a
 
      30th Jun 2005
Thanks, Elton. It isn't the syntax of how to create a filter that I need
help with, but where, *in the code generated by the Data Form Wizard*, the
filter should be applied, so that the grid on the form displays the matching
rows. When I apply the filter it is having no effect on the grid.
Regards
Timo


"Elton W" <(E-Mail Removed)> wrote in message
news:8B5018A4-E118-4F67-AB96-(E-Mail Removed)...
> Hi Timo,
>
> If you want to apply the filter to DB query, sql query is like
>
> SELECT * FROM VISITOR WHERE lastname LIKE 'J%'
>
> If you get whole data into a datatable then apply the filter, you can use
> following code:
>
> Dim dv As DataView = datatable.DefaultView
> dv.RowFilter = "lastname LIKE 'J%'"
>
> HTH
>
> Elton Wang
> (E-Mail Removed)
>
> "Timo" wrote:
>
> > I have to build dozens of simple data-entry forms in just a couple of

days,
> > and while I'm looking for a 3rd party tool that will help me do this, I
> > tried the Data Form Wizard in Visual Studio, which builds a persistent
> > dataset object based on a chosen table or view, and produces some basic
> > code-behind. The generated routine listed below binds the dataset member
> > (here, the VISITOR table) to a grid on the form.
> >
> > How and where can I modify this code to apply a filter to the VISITOR

table,
> > e.g. all visitors whose lastname begins with the letter 'J', so that

only
> > the J-names are shown in the grid?
> > Thanks
> > Timo
> >
> > '// generated by the Data Form wizard
> > Public Sub LoadDataSet()
> >
> > Dim objDataSetTemp As FormsWizardTest.dsvisitors
> > objDataSetTemp = New FormsWizardTest.dsvisitors
> > Try
> >
> > Me.FillDataSet(objDataSetTemp)
> >
> >
> > Catch eFillDataSet As System.Exception
> > Throw eFillDataSet
> > End Try
> >
> >
> > Try
> > grdVISITOR.DataSource = Nothing
> >
> > objdsvisitors.Clear()
> >
> > objdsvisitors.Merge(objDataSetTemp)
> > grdVISITOR.SetDataBinding(objdsvisitors, "VISITOR")
> >
> > grdVISITOR.
> >
> > Catch eLoadMerge As System.Exception
> >
> > Throw eLoadMerge
> > End Try
> >
> > End Sub
> >
> >
> >
> >



 
Reply With Quote
 
Bud Dean
Guest
Posts: n/a
 
      30th Jun 2005
Timo:

apply your filter in this area:

grdVISITOR.SetDataBinding(objdsvisitors, "VISITOR")

Create a dataview and aply the rowfilter. Then set the datasource of the
datgrid to the dataview, like Elton's example..

HTH,

bud
"Timo" <(E-Mail Removed)> wrote in message
news:(E-Mail Removed)...
> Thanks, Elton. It isn't the syntax of how to create a filter that I need
> help with, but where, *in the code generated by the Data Form Wizard*, the
> filter should be applied, so that the grid on the form displays the
> matching
> rows. When I apply the filter it is having no effect on the grid.
> Regards
> Timo
>
>
> "Elton W" <(E-Mail Removed)> wrote in message
> news:8B5018A4-E118-4F67-AB96-(E-Mail Removed)...
>> Hi Timo,
>>
>> If you want to apply the filter to DB query, sql query is like
>>
>> SELECT * FROM VISITOR WHERE lastname LIKE 'J%'
>>
>> If you get whole data into a datatable then apply the filter, you can use
>> following code:
>>
>> Dim dv As DataView = datatable.DefaultView
>> dv.RowFilter = "lastname LIKE 'J%'"
>>
>> HTH
>>
>> Elton Wang
>> (E-Mail Removed)
>>
>> "Timo" wrote:
>>
>> > I have to build dozens of simple data-entry forms in just a couple of

> days,
>> > and while I'm looking for a 3rd party tool that will help me do this, I
>> > tried the Data Form Wizard in Visual Studio, which builds a persistent
>> > dataset object based on a chosen table or view, and produces some basic
>> > code-behind. The generated routine listed below binds the dataset
>> > member
>> > (here, the VISITOR table) to a grid on the form.
>> >
>> > How and where can I modify this code to apply a filter to the VISITOR

> table,
>> > e.g. all visitors whose lastname begins with the letter 'J', so that

> only
>> > the J-names are shown in the grid?
>> > Thanks
>> > Timo
>> >
>> > '// generated by the Data Form wizard
>> > Public Sub LoadDataSet()
>> >
>> > Dim objDataSetTemp As FormsWizardTest.dsvisitors
>> > objDataSetTemp = New FormsWizardTest.dsvisitors
>> > Try
>> >
>> > Me.FillDataSet(objDataSetTemp)
>> >
>> >
>> > Catch eFillDataSet As System.Exception
>> > Throw eFillDataSet
>> > End Try
>> >
>> >
>> > Try
>> > grdVISITOR.DataSource = Nothing
>> >
>> > objdsvisitors.Clear()
>> >
>> > objdsvisitors.Merge(objDataSetTemp)
>> > grdVISITOR.SetDataBinding(objdsvisitors, "VISITOR")
>> >
>> > grdVISITOR.
>> >
>> > Catch eLoadMerge As System.Exception
>> >
>> > Throw eLoadMerge
>> > End Try
>> >
>> > End Sub
>> >
>> >
>> >
>> >

>
>



 
Reply With Quote
 
Timo
Guest
Posts: n/a
 
      30th Jun 2005
I had tried something like that already, but I get an error:

Dim DV As DataView
DV = objdsWebvisitors.Tables("VISITOR").DefaultView
DV.RowFilter = "lastname like 'J%'"

'// replaced this auto-generated line
'// grdWEBVISITOR.SetDataBinding(objdsWebvisitors, "VISITOR")

'// with this line:

grdWEBVISITOR.SetDataBinding(DV, "VISITOR")


The error is:

"Cannot create a child list for field VISITOR".

The .SetDataBinding method expects a string as the second argument. When the
first argument is a DataSet, the second argument is the name of the table.
But if the first argument is a DataView, what should the second argument be?

Thanks
Timo

"Bud Dean" <(E-Mail Removed)> wrote in message
news:eSes#(E-Mail Removed)...
> Timo:
>
> apply your filter in this area:
>
> grdVISITOR.SetDataBinding(objdsvisitors, "VISITOR")
>
> Create a dataview and aply the rowfilter. Then set the datasource of the
> datgrid to the dataview, like Elton's example..
>
> HTH,
>
> bud
> "Timo" <(E-Mail Removed)> wrote in message
> news:(E-Mail Removed)...
> > Thanks, Elton. It isn't the syntax of how to create a filter that I need
> > help with, but where, *in the code generated by the Data Form Wizard*,

the
> > filter should be applied, so that the grid on the form displays the
> > matching
> > rows. When I apply the filter it is having no effect on the grid.
> > Regards
> > Timo
> >
> >
> > "Elton W" <(E-Mail Removed)> wrote in message
> > news:8B5018A4-E118-4F67-AB96-(E-Mail Removed)...
> >> Hi Timo,
> >>
> >> If you want to apply the filter to DB query, sql query is like
> >>
> >> SELECT * FROM VISITOR WHERE lastname LIKE 'J%'
> >>
> >> If you get whole data into a datatable then apply the filter, you can

use
> >> following code:
> >>
> >> Dim dv As DataView = datatable.DefaultView
> >> dv.RowFilter = "lastname LIKE 'J%'"
> >>
> >> HTH
> >>
> >> Elton Wang
> >> (E-Mail Removed)
> >>
> >> "Timo" wrote:
> >>
> >> > I have to build dozens of simple data-entry forms in just a couple of

> > days,
> >> > and while I'm looking for a 3rd party tool that will help me do this,

I
> >> > tried the Data Form Wizard in Visual Studio, which builds a

persistent
> >> > dataset object based on a chosen table or view, and produces some

basic
> >> > code-behind. The generated routine listed below binds the dataset
> >> > member
> >> > (here, the VISITOR table) to a grid on the form.
> >> >
> >> > How and where can I modify this code to apply a filter to the VISITOR

> > table,
> >> > e.g. all visitors whose lastname begins with the letter 'J', so that

> > only
> >> > the J-names are shown in the grid?
> >> > Thanks
> >> > Timo
> >> >
> >> > '// generated by the Data Form wizard
> >> > Public Sub LoadDataSet()
> >> >
> >> > Dim objDataSetTemp As FormsWizardTest.dsvisitors
> >> > objDataSetTemp = New FormsWizardTest.dsvisitors
> >> > Try
> >> >
> >> > Me.FillDataSet(objDataSetTemp)
> >> >
> >> >
> >> > Catch eFillDataSet As System.Exception
> >> > Throw eFillDataSet
> >> > End Try
> >> >
> >> >
> >> > Try
> >> > grdVISITOR.DataSource = Nothing
> >> >
> >> > objdsvisitors.Clear()
> >> >
> >> > objdsvisitors.Merge(objDataSetTemp)
> >> > grdVISITOR.SetDataBinding(objdsvisitors, "VISITOR")
> >> >
> >> > grdVISITOR.
> >> >
> >> > Catch eLoadMerge As System.Exception
> >> >
> >> > Throw eLoadMerge
> >> > End Try
> >> >
> >> > End Sub
> >> >
> >> >
> >> >
> >> >

> >
> >

>
>



 
Reply With Quote
 
Timo
Guest
Posts: n/a
 
      30th Jun 2005
I found out the answer-- second argument can be String.Empty
Thanks for the help.
Timo


 
Reply With Quote
 
 
 
Reply

Thread Tools
Rate This Thread
Rate This Thread:

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are Off


Similar Threads
Thread Thread Starter Forum Replies Last Post
Filter keeps re-applying itself Brutuswa Microsoft Outlook BCM 0 22nd Jan 2010 08:21 AM
Applying more than 1 filter lecoughlin@gmail.com Microsoft Access 4 8th Jun 2007 11:09 PM
Applying a filter John Martin Microsoft Access Getting Started 2 20th Jan 2005 01:18 AM
applying a filter? Tom McDonnell Microsoft Access VBA Modules 0 7th Aug 2003 07:01 PM
Applying Filter Casey Howlett Microsoft Access 1 16th Jul 2003 04:01 PM


Features
 

Advertising
 

Newsgroups
 


All times are GMT +1. The time now is 01:16 PM.