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

DevOps Toolchain Recommendations

Read this Gartner Research Note and discover how your IT organization can automate and optimize DevOps processes using a toolchain architecture.

Question has a verified solution.

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

A quick way to get a menu to work on our website, is using the Menu control and assign it to a web.sitemap using SiteMapDataSource. Example of web.sitemap file: (CODE) Sample code to add to the page menu: (CODE) Running the application, we wi…
Many of us here at EE write code. Many of us write exceptional code; just as many of us write exception-prone code. As we all should know, exceptions are a mechanism for handling errors which are typically out of our control. From database errors, t…
This video shows how to remove a single email address from the Outlook 2010 Auto Suggestion memory. NOTE: For Outlook 2016 and 2013 perform the exact same steps. Open a new email: Click the New email button in Outlook. Start typing the address: …
This is a video that shows how the OnPage alerts system integrates into ConnectWise, how a trigger is set, how a page is sent via the trigger, and how the SENT, DELIVERED, READ & REPLIED receipts get entered into the internal tab of the ConnectWise …

919 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

16 Experts available now in Live!

Get 1:1 Help Now