Click here to Skip to main content
15,905,558 members
Please Sign up or sign in to vote.
0.00/5 (No votes)
See more:
Can Anyone crt following code:


in this code can't get the price value from db.how can i get the value from db.

price = '" + price_range+ "' it get only string as below Rs.500/- instead of this how can get values of less than 500 from database.


Error Coding:


protected void BulletedList3_Click(object sender, BulletedListEventArgs e)
   {

       price_range = BulletedList3.Items[e.Index].Value;
       if (con.State == ConnectionState.Closed)
       {
           con.Open();
       }
       switch (price_range)
       {
           case "Below Rs.500/-":
               SqlCommand cmd = new SqlCommand("select pro_img,pro_name,price from product where price = '" + price_range+ "' and status='A' and type='retail' ", con);
               SqlDataAdapter da = new SqlDataAdapter(cmd);
               DataSet ds = new DataSet();
               da.Fill(ds);
               DataList1.DataSource = ds;
               DataList1.DataBind();
               con.Close();
               break;
           case "Rs.500/- to Rs.1000/-":
               SqlCommand cmd1 = new SqlCommand("select pro_img,pro_name,price from product where price = '" + price_range + "' and status='A' and type='retail' ", con);
               SqlDataAdapter da1 = new SqlDataAdapter(cmd1);
               DataSet ds1 = new DataSet();
               da1.Fill(ds1);
               DataList1.DataSource = ds1;
               DataList1.DataBind();
               con.Close();
               break;
           case "Rs.1000/- To Rs.2000/-":
               SqlCommand cmd2 = new SqlCommand("select pro_img,pro_name,price from product where price = '" + price_range + "' and status='A' and type='retail' ", con);
               SqlDataAdapter da2= new SqlDataAdapter(cmd2);
               DataSet ds2 = new DataSet();
               da2.Fill(ds2);
               DataList1.DataSource = ds2;
               DataList1.DataBind();
               con.Close();
               break;
           default:
               break;
       }
   }
Posted
Updated 21-Nov-11 19:02pm
v2
Comments
Mehdi Gholam 22-Nov-11 0:41am    
What is your problem?
shek124 22-Nov-11 0:46am    
You cannot check the price range with price. it should be wrong
M.Narmatha 22-Nov-11 0:47am    
giv code for that.
M.Narmatha 22-Nov-11 0:46am    
price = '" + price_range+ "' it get only string as below Rs.500/- instead of this how can get values of less than 500 from database.
palraj001 22-Nov-11 1:56am    
how u give price range, is it from dropdownlist?

1 solution

For this range criteria you should use
SQL
between and
operator in SQL statement.

For example
SQL
Select * from table where price between 500 and 1000 



Regards
Sheik
 
Share this answer
 
Comments
M.Narmatha 22-Nov-11 0:49am    
k..but i d't where use this query inside my coding.

This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)



CodeProject, 20 Bay Street, 11th Floor Toronto, Ontario, Canada M5J 2N8 +1 (416) 849-8900