the find/filter function with xml database - datagridview

corey19981

New member
Joined
Mar 28, 2008
Messages
2
Programming Experience
Beginner
Hi there.

I have made a program that uses an accdb file (access database) to display a table with information on it.

I have used a 'find' function, where the user enters a valu into a textbox, and it searches the column for that string.

the code that I use is this:

VB.NET:
Private Sub btnIngamenamesearch_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles btnIngamenamesearch.Click

        If txtIngamename.Text = "" Then
            MessageBox.Show("Please enter a value!!", "doh!")

        Else


            DBBrowser.Close()
            DBBrowser.Show()

            Dim itemFound As Integer = DBBrowser.BindingSource1.Find("Game Name", txtIngamename.Text)

            DBBrowser.BindingSource1.Position = itemFound
        End If
        txtIngamename.Text = ""
    End Sub







However I have now decided to make my project work with an XML table instead.

all of the names (dbbrowser, bindingsource1 etc) are all still exactly the same. the only difference is that it connects to an xml instead of an access database file.


My program works perfectly with my xml file, the only thing that doesn't work is my search function.

if I enter in a value to search (one that is definately in the table), rather than, as usual, bringing me to the entry in the datagridview, it instead blurts out this error:

An unhandled exception of type 'System.ArgumentException' occurred in System.Windows.Forms.dll

Additional information: DataMember property 'Game Name' cannot be found on the DataSource.



the xml file that I'm using is an exact copy of my access database, so the column names etc are exactly the same.





secondly, another problem that I encountered no matter if I'm using an xml OR an access database, is that if for example:

under the column 'real name' there are TWO entries that read 'Martin'


if you search 'martin', it brings you to the first of the two entries, but for all my searcher knows, it could be the ONLY entry.

secondly, the find function doesn't appear to support wildcard or partial matches. in other words, if my user searched:

mar*
or
mart

the martin field would not be displayed, as if it isn't there.




I have learnt that there is a function called 'filter' which literally FILTERS the rows, so that it only shows the rows which contain the matching search term.

this would be much prefereed. even better if it supports partial matches.

Please help me.

Thanks

Corey :bigyello:


ps

my xml file was made with a 'writexml' function (I don't know how to convert it otherwise)

and here is a code snippet (starting from the beginning of the xml file) to give you an idea on what sort of syntax etc my xml is made in:


VB.NET:
<?xml version="1.0" standalone="yes"?>
<EPCDatabaseDataSet1 xmlns="http://tempuri.org/EPCDatabaseDataSet1.xsd">
  <EPCMemberQuery>
    <Game_x0020_Name>Gheist240</Game_x0020_Name>
    <Forum_x0020_Name>Gheist240</Forum_x0020_Name>
  </EPCMemberQuery>
  <EPCMemberQuery>
    <Forum_x0020_Name>Fleshmonkey</Forum_x0020_Name>
  </EPCMemberQuery>
  <EPCMemberQuery>
    <Game_x0020_Name>Admiral_Psycho</Game_x0020_Name>
    <Forum_x0020_Name>Admiral_Psycho</Forum_x0020_Name>
    <Country>USA</Country>
    <Membership_x0020_Status>Full</Membership_x0020_Status>
    <Ingame_x0020_Admin>Yes</Ingame_x0020_Admin>
  </EPCMemberQuery>
  <EPCMemberQuery>
    <Game_x0020_Name>Axel_</Game_x0020_Name>
    <Forum_x0020_Name>Axel_</Forum_x0020_Name>
    <Real_x0020_Name>Axel</Real_x0020_Name>
    <Birth_x0020_Date>28.02.95</Birth_x0020_Date>
    <Membership_x0020_Status>Full</Membership_x0020_Status>
    <Trial_x0020_Start_x0020_Date>March 10th 08</Trial_x0020_Start_x0020_Date>
    <Trial_x0020_End_x0020_Date>March 24th 08</Trial_x0020_End_x0020_Date>
  </EPCMemberQuery>
  <EPCMemberQuery>
    <Game_x0020_Name>bl00isdoom7</Game_x0020_Name>
    <Forum_x0020_Name>bl00isdoom7</Forum_x0020_Name>
    <Real_x0020_Name>Allan Golding</Real_x0020_Name>
    <Birth_x0020_Date>12.09.1996</Birth_x0020_Date>
    <Country>UK</Country>
    <Membership_x0020_Status>Trial</Membership_x0020_Status>
    <Email_x0020_Address>kingallan9000@hotmail.com</Email_x0020_Address>
    <MSN_x0020_Address>kingallan9000@hotmail.com</MSN_x0020_Address>
  </EPCMemberQuery>



and so on.

thankyou again!
 

Latest posts

Back
Top