MHenry
asked on
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:
And the select statement I have on the details page looks like this:
I'd appreciate some help making this work.
Thanks,
mh
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
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();
I'd appreciate some help making this work.
Thanks,
mh
ASKER CERTIFIED SOLUTION
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
ASKER