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
588 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
ID: 33719430
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
ID: 33719472
Excpets=Excpects  
0
 

Author Comment

by:nomar2
ID: 33734565
 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

Is Your Active Directory as Secure as You Think?

More than 75% of all records are compromised because of the loss or theft of a privileged credential. Experts have been exploring Active Directory infrastructure to identify key threats and establish best practices for keeping data safe. Attend this month’s webinar to learn more.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

If you're writing a .NET application to connect to an Access .mdb database and use pre-existing queries that require parameters, you've come to the right place! Let's say the pre-existing query(qryCust) in Access takes a Date as a parameter and l…
The ECB site provides FX rates for major currencies since its inception in 1999 in the form of an XML feed. The files have the following format (reducted for brevity) (CODE) There are three files available HERE (http://www.ecb.europa.eu/stats/exch…
This Micro Tutorial demonstrates using Microsoft Excel pivot tables, how to reverse engineer competitors' marketing strategies through backlinks.
Both in life and business – not all partnerships are created equal. As the demand for cloud services increases, so do the number of self-proclaimed cloud partners. Asking the right questions up front in the partnership, will enable both parties …

911 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

20 Experts available now in Live!

Get 1:1 Help Now