How to pass parameter from tbx to tableadapter and return result to different tbx

Posted on 2008-10-22
Last Modified: 2013-11-07

I have a tableadapter with a query that returns a list of customers using an account number as the parameter. What i need is to take a string entered into a textbox (tbxAccountNum) and pass that to the adapter (customersTableAdapter) when an imgbtn gets clicked. The result, I then need to populate into another textbox (tbxCompanyName).

Here is the query from my tableadapter (FillByAccountNum, GetCustomersByAccountNum)
SELECT account_num, company_name, customer_id FROM dbo.customers WHERE (account_num = @account_num)

I am using C#.

Please let me know if any additional information is required.
Question by:austerhaus
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
  • 3
  • 2
LVL 96

Expert Comment

by:Bob Learned
ID: 22785615
Are you calling a method on the TableAdapter where you need to pass a parameter?

int accountNumber = int.Parse(this.AccountNumber.Text);

Author Comment

ID: 22790501
Here is what I have:

protected void imgbtnSearch_Click(object sender, ImageClickEventArgs e)
        string accountNum = tbxAccountNum.Text;
        customersTableAdapter customersAdapter = new customersTableAdapter();

I had to change "int" to "string" and FillByAccountNum gives the error: No overload for method 'FillByAccountNum' takes '1' arguments. Is what I have thus far correct?

If so: How do I assign the value returned to tbxCustomerName?
LVL 96

Expert Comment

by:Bob Learned
ID: 22790577
The Intellisense should give you an understanding of what you need to do.  GetCustomersByAccountNum is a function with a return, that you are ignoring in this case.  You need to look and see what the return type is and assign the return value to the TextBox.

Author Comment

ID: 22831881
Thanks but intellisense is of little help. What is the "vanilla" way to pass a parameter to a datatable, obtain the response and assign that value to a textbox?
LVL 96

Accepted Solution

Bob Learned earned 500 total points
ID: 22832442
If you can't see how Intellisense is useful here, then you need to see how to use it:


Featured Post

Industry Leaders: 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

ASP.Net to Oracle Connectivity Recently I had to develop an ASP.NET application connecting to an Oracle database.As I am doing it first time ,I had to solve several problems. This article will help to such developers  to develop an ASP.NET client…
Problem Hi all,    While many today have fast Internet connection, there are many still who do not, or are connecting through devices with a slower connect, so light web pages and fast load times are still popular.    If your ASP.NET page …
Are you ready to implement Active Directory best practices without reading 300+ pages? You're in luck. In this webinar hosted by Skyport Systems, you gain insight into Microsoft's latest comprehensive guide, with tips on the best and easiest way…

730 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