Solved

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

Posted on 2008-10-22
7
718 Views
Last Modified: 2013-11-07
Hello,

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.
Thanks!
0
Comment
Question by:austerhaus
[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
  • 3
  • 2
7 Comments
 
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);
adapter.FillByAccountNum(accountNumber);
0
 
LVL 1

Author Comment

by:austerhaus
ID: 22790501
Here is what I have:

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

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?
0
 
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.
0
 
LVL 1

Author Comment

by:austerhaus
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?
0
 
LVL 96

Accepted Solution

by:
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:


DataAdapter-Intellisense.png
0

Featured Post

The Orion Papers

Are you interested in becoming an AWS Certified Solutions Architect?

Discover a new interactive way of training for the exam.

Question has a verified solution.

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

IntroductionWhile developing web applications, a single page might contain many regions and each region might contain many number of controls with the capability to perform  postback. Many times you might need to perform some action on an ASP.NET po…
The article shows the basic steps of integrating an HTML theme template into an ASP.NET MVC project
Monitoring a network: how to monitor network services and why? Michael Kulchisky, MCSE, MCSA, MCP, VTSP, VSP, CCSP outlines the philosophy behind service monitoring and why a handshake validation is critical in network monitoring. Software utilized …
Add bar graphs to Access queries using Unicode block characters. Graphs appear on every record in the color you want. Give life to numbers. Hopes this gives you ideas on visualizing your data in new ways ~ Create a calculated field in a query: …

724 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