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
593 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
[X]
Welcome to Experts Exchange

Add your voice to the tech community where 5M+ people just like you are talking about what matters.

  • Help others & share knowledge
  • Earn cash & points
  • Learn & ask questions
  • 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

Technology Partners: We Want Your Opinion!

We value your feedback.

Take our survey and automatically be enter to win anyone of the following:
Yeti Cooler, Amazon eGift Card, and Movie eGift Card!

Question has a verified solution.

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

Suggested Solutions

Title # Comments Views Activity
Crystal reports login after closing form 3 53
Send SMS from vb.net desktop app 30 45
Check only one toolstripmenu item 12 55
Adding Rows to Grid 4 26
This tutorial demonstrates one way to create an application that runs without any Forms but still has a GUI presence via an Icon in the System Tray. The magic lies in Inheriting from the ApplicationContext Class and passing that to Application.Ru…
If you need to start windows update installation remotely or as a scheduled task you will find this very helpful.
Nobody understands Phishing better than an anti-spam company. That’s why we are providing Phishing Awareness Training to our customers. According to a report by Verizon, only 3% of targeted users report malicious emails to management. With compan…
Exchange organizations may use the Journaling Agent of the Transport Service to archive messages going through Exchange. However, if the Transport Service is integrated with some email content management application (such as an antispam), the admini…

740 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