help with using parameter in query string. asp.net, c#

I found an example of how to do an SQL query that I really liked. It's nice and clean so I figured I would change what I normally do. But now I don't know how to use the parameter correctly using this style of code.

Basically, it's a master/detail situation. I have a query string being passed and it has the right value. What I want is a select statement that will pull the details where the AccountID =AAMPRA0016A - just like what the string being passed says. So that part seems to be fine.

My query string from the preceding page looks like this:
http://localhost:30559/Portal/oppDetail.aspx?ACCOUNT.ACCOUNTID=AAMPRA0016AQ

Open in new window


And the select statement I have on the details page looks like this:
SqlDataSource SqlDataSource1 = new SqlDataSource();
                    SqlDataSource1.ID = "SqlDataSource1";
                    this.Page.Controls.Add(SqlDataSource1);
                    SqlDataSource1.ConnectionString = System.Configuration.ConfigurationManager.ConnectionStrings["qConnectionString"].ConnectionString;
                    SqlDataSource1.SelectCommand = "SELECT OPPORTUNITY.DESCRIPTION, OPPORTUNITY.SALESPOTENTIAL, OPPORTUNITY.STAGE, OPPORTUNITY.REGISTERED FROM ACCOUNT INNER JOIN OPPORTUNITY ON ACCOUNT.ACCOUNTID = OPPORTUNITY.ACCOUNTID WHERE (ACCOUNT.ACCOUNTID = ?)";
                    SqlDataSource1.SelectParameters.Equals("@ACCOUNT.ACCOUNTID");
                    DetailsView1.DataSource = SqlDataSource1;
                    DetailsView1.DataBind();

Open in new window


I'd appreciate some help making this work.

Thanks,
mh
LVL 7
MHenryAsked:
Who is Participating?
I wear a lot of hats...

"The solutions and answers provided on Experts Exchange have been extremely helpful to me over the last few years. I wear a lot of hats - Developer, Database Administrator, Help Desk, etc., so I know a lot of things but not a lot about one thing. Experts Exchange gives me answers from people who do know a lot about one thing, in a easy to use platform." -Todd S.

Robert SchuttSoftware EngineerCommented:
Please try this:

in the select statement on line 5, replace ? with @ACCOUNTID

replace line 6 with:
SqlDataSource1.SelectParameters.Add(new QueryStringParameter("ACCOUNTID", System.Data.DbType.String, "ACCOUNT.ACCOUNTID"));

Open in new window

0

Experts Exchange Solution brought to you by

Your issues matter to us.

Facing a tech roadblock? Get the help and guidance you need from experienced professionals who care. Ask your question anytime, anywhere, with no hassle.

Start your 7-day free trial
MHenryAuthor Commented:
Awesome, thanks!
0
It's more than this solution.Get answers and train to solve all your tech problems - anytime, anywhere.Try it for free Edge Out The Competitionfor your dream job with proven skills and certifications.Get started today Stand Outas the employee with proven skills.Start learning today for free Move Your Career Forwardwith certification training in the latest technologies.Start your trial today
ASP.NET

From novice to tech pro — start learning today.

Question has a verified solution.

Are you are experiencing a similar issue? Get a personalized answer when you ask a related question.

Have a better answer? Share it in a comment.