Results 1 to 12 of 12

Thread: Finding row position of a Data Table

Hybrid View

  1. #1
    VB Addict Pradeep1210's Avatar
    Join Date
    Apr 2004
    Location
    Inside the CPU...
    Posts
    6,614

    Re: Finding row position of a Data Table

    Quote Originally Posted by rushy View Post
    wow, thanks, works a treat, however having a slight issue that i had more than one customer in the combo box, but the filtering seems to leave me with just the Customer that has been selected. Thanks again
    You can modify the filter according to your needs.
    It is basically the WHERE part of your SQL statement.

    e.g.
    Code:
    dttblCustomer.DefaultView.RowFilter = "CustomerID=1 OR CustomerID=2 OR CustomerID=3"
    If it would be getting too complex, then it is always better to fill your datatable with only rows of your interest from your database with appropriate SQL query.
    Pradeep, Microsoft MVP (Visual Basic)
    Please appreciate posts that have helped you by clicking icon on the left of the post.
    "A problem well stated is a problem half solved." — Charles F. Kettering

    Read articles on My Blog101 LINQ SamplesJSON ValidatorXML Schema Validator"How Do I" videos on MSDNVB.NET and C# ComparisonGood Coding PracticesVBForums Reputation SaverString EnumSuper Simple Tetris Game


    (2010-2013)
    NB: I do not answer coding questions via PM. If you want my help, then make a post and PM me it's link. If I can help, trust me I will...

  2. #2

    Thread Starter
    Junior Member
    Join Date
    Apr 2006
    Posts
    17

    Re: Finding row position of a Data Table

    The problem i have is that it doesnt seem to filter down the customers, it will just show the customer in row(0) and therefore doesnt change at all when i change the number in the combo box. This is the reason i was looking for a little bit of help in getting the row position of the customername with customerid = combobox

    your help so fars much appreciated though!
    Last edited by rushy; Feb 27th, 2011 at 02:57 PM.

  3. #3
    New Member
    Join Date
    Dec 2013
    Posts
    1

    Red face Re: Finding row position of a Data Table

    Quote Originally Posted by rushy View Post
    The problem i have is that it doesnt seem to filter down the customers, it will just show the customer in row(0) and therefore doesnt change at all when i change the number in the combo box. This is the reason i was looking for a little bit of help in getting the row position of the customername with customerid = combobox

    your help so fars much appreciated though!
    I want to tell you, that in the datasources tab, you make a connection with your database server and from there for example, you can drag the customer ID from the customer table to the CustomerID textbox and all the other fields that you want to link in your textboxes that you want to select the primary key from as your source, and then for example, if you have a related table, under the hierarchy of relations you select the table of the other table that you want to link for example Orders to the combobox, and it will take care of the DisplayMember (this is what you want to show inside the comboxBox) and the ValueMember (This is the CustomerID that you want to save in the other table that you want)

    also for example, if you want to find a member or customer, then in the selected_change event of the comboBox, you write the code to call a Query for the CustomerTableAdapter.FillByCustomerID(CustomerDataTable, ComboBox.SelectedValue) This way it will take you directly to the record that you want to display through the bindingsource that is already automatically link with the previous drag that you performed.

    Hope this works for you, there are many ways of doing this task, also using the datatable.select("CustomerID = '" & comboBox.SelectedValue & "'")

    Good Luck

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •  



Click Here to Expand Forum to Full Width