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
590 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

Best Practices: Disaster Recovery Testing

Besides backup, any IT division should have a disaster recovery plan. You will find a few tips below relating to the development of such a plan and to what issues one should pay special attention in the course of backup planning.

Question has a verified solution.

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

Well, all of us have seen the multiple EXCEL.EXE's in task manager that won't die even if you call the .close, .dispose methods. Try this method to kill any excels in memory. You can copy the kill function to create a check function and replace the …
Article by: Kraeven
Introduction Remote Share is a simple remote sharing tool, enabling you to see, add and remove remote or local shares. The application is written in VB.NET targeting the .NET framework 2.0. The source code and the compiled programs have been in…
This Micro Tutorial demonstrates using Microsoft Excel pivot tables, how to reverse engineer competitors' marketing strategies through backlinks.
Email security requires an ever evolving service that stays up to date with counter-evolving threats. The Email Laundry perform Research and Development to ensure their email security service evolves faster than cyber criminals. We apply our Threat…

803 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