How to write select command for starting amount to End amount.
For Example: Mobile Shop Select Mobile Company Name: Samsung and From amount=1500 to End amount=15000. i want show this two different Mobile Models.
Pls Send With Example.
Thanks&Regs
Magesh.A
Loading
magesh manavalanPosted Mar 24, 2012, 4:56 AM
SenthilkumarPosted Mar 24, 2012, 4:53 AM
Company name: Samsung, HTC, Nokia, Motorola
Range : Start Amount: ------- End Range:---------
SELECT * FROM mobileModels WHERE (Amount between StartAmount AND EndRange) AND CompanyName='Sansung'
Satyapriya NayakPosted Mar 24, 2012, 1:43 AM
<%@ Page Language="C#" AutoEventWireup="true" CodeBehind="WebForm2.aspx.cs" Inherits="Paging_in_GridView.WebForm2" %>
using System;
using System.Collections;
using System.Configuration;
using System.Data;
using System.Linq;
using System.Web;
using System.Web.Security;
using System.Web.UI;
using System.Web.UI.HtmlControls;
using System.Web.UI.WebControls;
using System.Web.UI.WebControls.WebParts;
using System.Xml.Linq;
using System.Data.SqlClient;
namespace Paging_in_GridView
{
public partial class WebForm2 : System.Web.UI.Page
{
string connStr = ConfigurationManager.ConnectionStrings["ConnectionString"].ConnectionString;
SqlCommand com;
string str;
protected void Page_Load(object sender, EventArgs e)
{
DropDownList1.AutoPostBack = true;
SqlConnection con = new SqlConnection(connStr);
if (!IsPostBack)
{
DropDownList1.Items.Add("Choose range");
con.Open();
str = "select * from amtcat";
com = new SqlCommand(str, con);
SqlDataReader reader = com.ExecuteReader();
while (reader.Read())
{
DropDownList1.Items.Add(reader["amount"].ToString());
}
reader.Close();
con.Close();
}
}
protected void DropDownList1_SelectedIndexChanged(object sender, EventArgs e)
{
ListBox1.Items.Clear();
SqlConnection con = new SqlConnection(connStr);
con.Open();
str = "select model from Mobile where id='" + DropDownList1.SelectedItem.Text + "'";
com = new SqlCommand(str, con);
SqlDataReader reader = com.ExecuteReader();
while (reader.Read())
{
ListBox1.Items.Add ( reader["model"].ToString());
}
reader.Close();
con.Close();
}
}
}
Thanks
If this post helps you mark it as answer
magesh manavalanPosted Mar 24, 2012, 12:55 AM
magesh manavalanPosted Mar 24, 2012, 12:33 AM
Satyapriya NayakPosted Mar 24, 2012, 12:26 AM
SELECT Company Name
FROM tablename
WHERE (amount BETWEEN 1500 AND 15000)
Thanks