Solved

VB.Net 2005 How to get a Table Adapter to display a certain record based on a parameter passed in ??

Posted on 2010-09-20
3
585 Views
Last Modified: 2012-05-10
I am using VB.Net 2005..

I have on the Load Event of the form... a Table adapter that shows all the records of the tCust table

       Me.TCustTableAdapter.Fill(Me.RecycleDataSet1.tCust)
        Dim sql As String
        Dim da1 As SqlClient.SqlDataAdapter
        Dim ds1 As DataSet = New DataSet

There are about  1000 records that are being returned.. the "ID" field of the Customer table is tCust.lID...if I wanted to get the table adapter to load based on a ID passed into it ..

For example instead of seeing all the records.. I want to see..tCust.lId = 150

What would the code look like?

Any insight would be greatly appreciated...
0
Comment
Question by:nomar2
  • 2
3 Comments
 
LVL 18

Accepted Solution

by:
John (Yiannis) Toutountzoglou earned 111 total points
Comment Utility
there ways you can do that ...
Or By using The BindingSource.Filter
Or Create a query in your dataset Designer ...you can insert there a Where Clause :    WHERE ID=@ID
then your TableAdapter Excpets a parameter..
 Me.TCustTableAdapter.FillByID(Me.RecycleDataSet1.tCust,Me.TextBox1.Text)    > (For Example)
0
 
LVL 18

Expert Comment

by:John (Yiannis) Toutountzoglou
Comment Utility
Excpets=Excpects  
0
 

Author Comment

by:nomar2
Comment Utility
 I sed the      
I used BindingSource.Filter Based on your suggestion..here is the sample code

Me.TCustTableAdapter.Fill(Me.RecycleDataSet1.tCust)
        Dim lnTestid As Integer
        lnTestid = 1000
        Me.TCustBindingSource.Filter = "lID=" & lnTestid & ""
        Dim sql As String
        Dim da1 As SqlClient.SqlDataAdapter
        Dim ds1 As DataSet = New DataSet
        con.Open()
        sql = "SELECT iID,sCustPayType from tCustPayType"
        da1 = New SqlDataAdapter(sql, con)
        da1.Fill(ds1, "tCustPayType")
0

Featured Post

What Should I Do With This Threat Intelligence?

Are you wondering if you actually need threat intelligence? The answer is yes. We explain the basics for creating useful threat intelligence.

Join & Write a Comment

Article by: jpaulino
XML Literals are a great way to handle XML files and the community doesn’t use it as much as it should.  An XML Literal is like a String (http://msdn.microsoft.com/en-us/library/system.string.aspx) Literal, only instead of starting and ending with w…
Introduction When many people think of the WebBrowser (http://msdn.microsoft.com/en-us/library/2te2y1x6%28v=VS.85%29.aspx) control, they immediately think of a control which allows the viewing and navigation of web pages. While this is true, it's a…
Internet Business Fax to Email Made Easy - With eFax Corporate (http://www.enterprise.efax.com), you'll receive a dedicated online fax number, which is used the same way as a typical analog fax number. You'll receive secure faxes in your email, fr…
When you create an app prototype with Adobe XD, you can insert system screens -- sharing or Control Center, for example -- with just a few clicks. This video shows you how. You can take the full course on Experts Exchange at http://bit.ly/XDcourse.

762 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question

Need Help in Real-Time?

Connect with top rated Experts

9 Experts available now in Live!

Get 1:1 Help Now