QueryString

Last post 05-27-2008 3:02 AM by Spanco. 5 replies.

Sort Posts:

  • QueryString

    05-26-2008, 6:03 AM
    • Member
      64 point Member
    • ckmurthy
    • Member since 03-11-2008, 2:12 PM
    • Posts 74

     Hi guys, i used usercontrol in my home page,in that page like LCD,Comuters,Laptops like there are different types of categories are there.how can i retrive the exact product from the databse.my code is bellow.

    in default.aspx.cs :-

     

      
                 if (Request.QueryString["ProductName"] == "laptop")
                {
                    //sql = "select * from Products where CategoryID=10 and Productname like'"+dell+"'";
                    string cid = Request.QueryString["CategoryID"].ToString();
                    string categ = "Laptops";
                    sql = "select * from Products where (CategoryID='" + cid + "') and ((ProductName like '" + categ.ToString() + "%') or (ProductName like '" + notebook + "%'))";
                    viewdata(sql);
                }

     

    I passed querystring in usercontrlo like this.

     

    <td height="18" align="left" valign="top" background="images/pole_2a.jpg">
                                <div style="padding-left: 12px; padding-top: 0px">
                                    <a href="Default.aspx?CategoryID=10&ProductName=laptop" class="style7" style="text-decoration: none">
                                        Laptops & Notebooks</a></div>
                            </td>

     

    but it is not working for me.

    if any body knows plz help me,Thanks in advance.

    Krishnamurthy C
    Consultant,
    Holmdel Consulting,
    krishnamurthy@holmdelconsulting.com
    www.holmdelconsulting.com
  • Re: QueryString

    05-26-2008, 7:10 AM
    • Participant
      1,255 point Participant
    • Abhishek khanna
    • Member since 05-01-2008, 6:01 PM
    • India
    • Posts 217

    Hi

    I think your query looks better & logical like this:

    string sql = "select * from Products where (CategoryID='" + cid + "') and ((ProductName like '%laptop%') or (ProductName like '%notebook%'))";

    Please make this change, this should work out for you.

    Hope this helps.

  • Re: QueryString

    05-26-2008, 7:11 AM
    • Participant
      1,228 point Participant
    • Spanco
    • Member since 06-11-2007, 1:51 AM
    • New Delhi, India
    • Posts 336

     The code seems to be right ,can u please post the error also.

    Nothing is impossible as the IMPOSSIBLE word itself says I M Possible...just you have to try..u get all what you desire

    Pradeep Bisht
    BLOG ::--> http://dotnetarmy.blogspot.com/
    URL ::--> http://www.asp.net
  • Re: QueryString

    05-27-2008, 12:10 AM
    • Member
      64 point Member
    • ckmurthy
    • Member since 03-11-2008, 2:12 PM
    • Posts 74

     Query is working properly but i didn't get exact data from the databse and also no data will be displayed.

    Krishnamurthy C
    Consultant,
    Holmdel Consulting,
    krishnamurthy@holmdelconsulting.com
    www.holmdelconsulting.com
  • Re: QueryString

    05-27-2008, 12:53 AM
    • Participant
      1,255 point Participant
    • Abhishek khanna
    • Member since 05-01-2008, 6:01 PM
    • India
    • Posts 217

    Can you please post your viewdata(sql) code.

  • Re: QueryString

    05-27-2008, 3:02 AM
    Answer
    • Participant
      1,228 point Participant
    • Spanco
    • Member since 06-11-2007, 1:51 AM
    • New Delhi, India
    • Posts 336

     To write the query according to ur need is ur responsibility we can help u out ,well how u are showing ur data(this code is in ur viewdata function )

    U have to give us that one

    Iam sure thers is a problem in the binding as u r saying u are getting the data but the result are wrong.

     

     

    Nothing is impossible as the IMPOSSIBLE word itself says I M Possible...just you have to try..u get all what you desire

    Pradeep Bisht
    BLOG ::--> http://dotnetarmy.blogspot.com/
    URL ::--> http://www.asp.net
Page 1 of 1 (6 items)