TECHNOLOGIES
FORUMS
JOBS
BOOKS
EVENTS
INTERVIEWS
Live
MORE
LEARN
Training
CAREER
MEMBERS
VIDEOS
NEWS
BLOGS
Sign Up
Login
No unread comment.
View All Comments
No unread message.
View All Messages
No unread notification.
View All Notifications
Answers
Post
An Article
A Blog
A News
A Video
An EBook
An Interview Question
Ask Question
Forums
Monthly Leaders
Forum guidelines
selvi subramanian
NA
799
572.6k
in frontend it throw error
Sep 17 2013 5:48 AM
Subquery returned more than 1 value. This is not permitted when the subquery follows =, !=, <, <= , >, >= or when the subquery is used as an expression.
My design
<form id="form1" runat="server">
<p>
<br />
<table class="style2" align="center" style="border-color: #1d599e; border-style: outset;
border-width: thin; background-color: #D7D7D7; width:50%" >
<tr>
<td style="margin-left: 80px; background:#1d599e;" align="center" colspan="2">
BILLING DETAILS
</td>
</tr>
<tr>
<td colspan="2">
</td>
</tr>
<tr align="left">
<td>
<asp:Label ID="Label1" runat="server" Text="Product" Visible="false"></asp:Label>
</td>
<td>
<asp:TextBox ID="TextBox2" runat="server" Visible="false" Text="Cement"></asp:TextBox>
</td>
</tr>
<tr align="left">
<td>
<asp:Label ID="Label2" runat="server" Text="Date"></asp:Label>
</td>
<td>
<asp:TextBox ID="txtdate" runat="server"></asp:TextBox>
</td>
</tr>
<tr align="left">
<td>
<asp:Label ID="Label3" runat="server" Text="BillNo"></asp:Label>
</td>
<td>
<asp:TextBox ID="txtbillno" runat="server"
></asp:TextBox>
</td>
</tr>
<tr align="left">
<td>
<asp:Label ID="Label4" runat="server" Text="Customer Name"></asp:Label>
</td>
<td>
<asp:TextBox ID="txtcn" runat="server" ></asp:TextBox>
</td>
</tr>
<tr align="left">
<td>
<asp:Label ID="Label5" runat="server" Text="Address"></asp:Label>
</td>
<td>
<asp:TextBox ID="txtad" runat="server"></asp:TextBox>
</td>
</tr>
<tr align="left">
<td>
<asp:Label ID="Label6" runat="server" Text="Brand Name"></asp:Label> </td>
<td>
<asp:DropDownList ID="DropDownList1" runat="server" AutoPostBack="True"
onselectedindexchanged="DropDownList1_SelectedIndexChanged" Width="146px"
AppendDataBoundItems="True">
<asp:ListItem>--Select--</asp:ListItem>
</asp:DropDownList>
</td>
</tr>
<tr align="left">
<td>
<asp:Label ID="Label7" runat="server" Text="Quantity"></asp:Label> </td>
<td>
<asp:DropDownList ID="DropDownList2" runat="server" AutoPostBack="True"
onselectedindexchanged="DropDownList2_SelectedIndexChanged" Height="16px"
Width="146px">
</asp:DropDownList>
</td>
</tr>
<tr align="left">
<td>
<asp:Label ID="Label8" runat="server" Text="Product Price"></asp:Label>
</td>
<td>
<asp:TextBox ID="TextBox1" runat="server"></asp:TextBox>
</td>
</tr>
<tr>
<td>
<asp:Label ID="Label11" runat="server" Text="Required No"></asp:Label>
</td>
<td width="20px">
<asp:DropDownList ID="DropDownList3" runat="server" AutoPostBack="true"
onselectedindexchanged="DropDownList3_SelectedIndexChanged" Width="149px" >
</asp:DropDownList>
</td>
<td>
</td>
</tr>
<tr>
<td>
<asp:Label ID="Label12" runat="server" Text="Price"></asp:Label>
</td>
<td>
<asp:TextBox ID="txttp" runat="server" AutoPostBack="true"
></asp:TextBox>
</td>
</tr>
<tr visible="false">
<td visible="false">
<asp:Label ID="Label14" runat="server" Text="before vat"></asp:Label> </td>
<td>
<asp:TextBox ID="TextBox6" runat="server" AutoPostBack="true"
ontextchanged="TextBox6_TextChanged"></asp:TextBox>
</td>
</tr>
<tr>
<td>
<asp:Label ID="Label13" runat="server" Text="Extra"></asp:Label>
</td>
<td>
<asp:TextBox ID="txtvat" runat="server" ontextchanged="txtvat_TextChanged" AutoPostBack="true" ></asp:TextBox>
</td>
</tr>
<tr>
<td>
<asp:Label ID="Label16" runat="server" Text="correct price" ></asp:Label> </td>
<td>
<asp:TextBox ID="TextBox7" runat="server"></asp:TextBox>
</td>
</tr>
<tr>
<td>
<asp:Label ID="Label17" runat="server" Text="Actual price"></asp:Label>
</td>
<td>
<asp:TextBox ID="TextBox3" runat="server" AutoPostBack="true"
ontextchanged="TextBox3_TextChanged" ></asp:TextBox>
</td>
</tr>
<tr align="left">
<td>
<asp:Label ID="Label9" runat="server" Text="VAT"></asp:Label>
</td>
<td>
<asp:TextBox ID="txtex" runat="server"
AutoPostBack="true" Text="(14.5/100)" ReadOnly="True" ></asp:TextBox>
<asp:TextBox ID="TextBox4" runat="server" AutoPostBack="True"
ontextchanged="TextBox4_TextChanged"></asp:TextBox>
</td>
</tr>
<tr align="left">
<td>
<asp:Label ID="Label15" runat="server" Text="Total Amount"></asp:Label>
</td>
<td>
<asp:TextBox ID="TextBox5" runat="server"></asp:TextBox>
</td>
</tr>
<tr>
<td>
type
</td>
<td>
<asp:TextBox ID="TextBox8" runat="server" Text="s"></asp:TextBox>
</td>
</tr>
<tr>
<td colspan="2" align="center">
<asp:Button ID="Button1" runat="server" Text="Submit" onclick="Button1_Click" />
<asp:Label ID="Label10" runat="server" Text=""></asp:Label>
<asp:Button ID="Button2" runat="server" Text="clear" onclick="Button2_Click" />
<asp:Button ID="Button3" runat="server" Text="Print" onclick="Button3_Click" />
</td>
</tr>
</table>
</p>
<p>
</p>
<p>
</p>
<p>
</p>
<p>
</p>
</form>
Coding
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;
using TestWebMsgApp;
using NTRUHS;
public partial class Admin_Default : System.Web.UI.Page
{
REMO sel = new REMO();
DataSet ds = new DataSet();
// string s = ConfigurationManager.AppSettings["RM"].ToString();
SqlConnection cn;
SqlCommand cd = new SqlCommand();
SqlDataAdapter da = new SqlDataAdapter();
public int se;
public float sl;
public Admin_Default()
{
//cn = new SqlConnection("Data Source=VALUED-HO1E64NO\\SQLEXPRESS;Initial Catalog=Agri;User ID=sa;Password=watt;Integrated Security =True");
// cn.Open();
}
protected void Page_Load(object sender, EventArgs e)
{
if (!IsPostBack)
{
LoadQuantity();
//prr();
sno();
pqice();
txtdate.Text = System.DateTime.Now.ToString("dd-MM-yyyy");
}
}
private void sno()
{
string bill=sel.getmaxid("BillNo", "cement1");
txtbillno.Text = bill.ToString();
/* // int z = 0;
//ListItem cb = new ListItem();
// ds = sel.GETDS("select Billno from numbeer");
ds = sel.GETDS("select min (Billno) as Billno from numbeer where status='view'");
foreach (DataRow dr in ds.Tables[0].Rows)
{
//ListItem sw = new ListItem();
txtbillno.Text = dr["Billno"].ToString();
//sw.Value = Convert.ToString(z + 1);
}*/
}
private void pqice()
{
ListItem lik = new ListItem();
// lik.Text = "Select";
DropDownList3.Items.Insert(0, new ListItem("--Select--", "0"));
lik.Value = "0";
for (int se = 1; se <= 700; se++)
{
DropDownList3.Items.Add(Convert.ToString(se));
}
}
private void prr()
{
int s = 0;
ListItem lim = new ListItem();
//lim.Text = "Select";
//lim.Value = "0";
//DropDownList1.Items.Add(lim.ToString());
ds = sel.GETDS("select DISTINCT name from demo");
//DropDownList1.Items.Insert(0, new ListItem("--Select--", "0"));
foreach (DataRow dr in ds.Tables[0].Rows)
{
DropDownList1.Items.Clear();
ListItem ss = new ListItem();
lim.Text = dr["name"].ToString();
lim.Value = Convert.ToString(s + 1);
DropDownList1.Items.Add(lim.ToString());
}
}
void LoadQuantity()
{
ds = sel.GETDS("select DISTINCT name from demo");
foreach (DataRow dr in ds.Tables[0].Rows)
{
// DropDownList1.Items.Clear();
ListItem ss = new ListItem();
ss.Text = dr["name"].ToString();
//ss.Value = Convert.ToString(s + 1);
DropDownList1.Items.Add(ss.ToString());
}
}
protected void DropDownList1_SelectedIndexChanged(object sender, EventArgs e)
{
DropDownList2.Items.Clear();
DataSet ds = new DataSet();
string qr = "select weight from demo where name='" + DropDownList1.SelectedValue.ToString() + "'";
ds = sel.GETDS(qr);
ListItem se = new ListItem();
//se.Value = "0";
//se.Text = "Select";
DropDownList2.Items.Insert(0, new ListItem("--Select--", "0"));
foreach (DataRow dr in ds.Tables[0].Rows)
{
ListItem liz = new ListItem();
//liz.Text = "Select";
liz.Value = dr["weight"].ToString();
DropDownList2.Items.Add(liz.ToString());
}
}
protected void DropDownList2_SelectedIndexChanged(object sender, EventArgs e)
{
ListItem sss = new ListItem();
// sss.Text = "Select";
DropDownList2.Items.Insert(0, new ListItem("--Select--", "0"));
DataSet ds = new DataSet();
string sq = "select price from demo where weight='" + DropDownList2.SelectedItem.ToString() + "'";
ds = sel.GETDS(sq);
TextBox1.Text = ds.Tables[0].Rows[0]["price"].ToString();
foreach (DataRow dr in ds.Tables[0].Rows)
{
TextBox1.Text = dr["price"].ToString();
}
}
protected void Button1_Click(object sender, EventArgs e)
{
/* string qrt = "exec ins_cement values ('" + txtdate.Text;
qrt += "','" + txtbillno.Text;
qrt += "','" + txtcn.Text;
qrt += "','" + txtad.Text;
qrt += "','" + DropDownList1.SelectedItem.ToString();
qrt += "','" + DropDownList2.SelectedItem.ToString();
qrt += "','" + TextBox1.Text;
// qrt += "','" + ddprice.SelectedItem.ToString();
qrt += "','" + txtex.Text;
qrt += "')";
sel.Insert(qrt);
Label10.Visible = true;
Label10.Text = "Sucess";
cn = new SqlConnection(s);
//cn.Open();
//string qrs = "insert into product (date,Product,BillNo,ProductName,Quantity,Price,Extra) values ('" + txtdate.Text;
//qrs += "','" + TextBox2.Text;
//qrs += "','" + txtbillno.Text;
////sqrs += "','" + txtcn.Text;
//qrs += "','" + DropDownList1.SelectedItem.ToString();
//qrs += "','" + DropDownList2.SelectedItem.ToString();
//qrs += "','" + TextBox1.Text;
////qrs += "','" + ddprice.SelectedItem.ToString();
//qrs += "','" + txtex.Text;
//qrs += "')";
////sel.Insert(qrs);
//cd = new SqlCommand(qrs, cn);
//cd.ExecuteNonQuery();
//cn.Close();
string up = "update numbeer set status='Viewed' where Billno='" + txtbillno.Text + "'";
sel.Insert(up);*/
SqlParameter[] p = new SqlParameter[15];
try
{
p[0] = new SqlParameter("@Product", TextBox2.Text);
p[1] = new SqlParameter("@Date", txtdate.Text);
p[2] = new SqlParameter("@BillNo", txtbillno.Text);
p[3] = new SqlParameter("@CustomerName", txtcn.Text);
p[4] = new SqlParameter("@Address", txtad.Text);
p[5] = new SqlParameter("@BrandName", DropDownList1.SelectedItem.Text);
p[6] = new SqlParameter("@Quantity", DropDownList2.SelectedItem.Text);
p[7] = new SqlParameter("@ProductPrice", TextBox1.Text);
p[8] = new SqlParameter("@Requiredno", DropDownList3.SelectedItem.Text);
p[9] = new SqlParameter("@Price", txttp.Text);
p[10] = new SqlParameter("@Extra", txtvat.Text);
p[11] = new SqlParameter("@Vat", txtex.Text);
p[12] = new SqlParameter("@TotalAmount", TextBox7.Text);
p[13] = new SqlParameter("@CorrectPrice", TextBox5.Text);
p[14] = new SqlParameter("@type", TextBox8.Text);
int res = SqlHelper.ExecuteNonQuery(Cls_Connection.ConnectionString, CommandType.StoredProcedure, "im", p);
if (res == 2)
{
WebMsgBox.Show("Product Data Submited Successfully ");
Session["bno"] = txtbillno.Text;
//ScriptManager.RegisterStartupScript(Page, typeof(Page), "OpenWindow", "window.open('cementreport.aspx');", true);
clear();
}
else
{
WebMsgBox.Show("Product Data Not Submited");
}
}
catch( Exception e1)
{
}
}
protected void Button2_Click(object sender, EventArgs e)
{
clear();
}
public void clear()
{
//txtdate.Text = "";
txtbillno.Text = "";
txtcn.Text = "";
txtad.Text = "";
DropDownList1.SelectedIndex = 0;
DropDownList2.SelectedIndex = 0;
DropDownList3.SelectedIndex = 0;
txttp.Text = "";
TextBox6.Text = "";
txtvat.Text = "";
TextBox7.Text = "";
TextBox3.Text = "";
TextBox1.Text = "";
//txtex.Text = "";
TextBox4.Text = "";
TextBox5.Text = "";
sno();
}
protected void DropDownList3_SelectedIndexChanged(object sender, EventArgs e)
{
float sl =(Convert.ToSingle(DropDownList3.Text)* Convert.ToSingle(TextBox1.Text));
txttp.Text = Convert.ToString(sl);
TextBox6.Text = (int.Parse(txttp.Text) * (14.5 / 100)).ToString();
}
protected void txtvat_TextChanged(object sender, EventArgs e)
{
float amm=(float.Parse(txttp.Text)+float.Parse(txtvat.Text));
TextBox3.Text = Convert.ToString(amm);
double guna = int.Parse(TextBox3.Text) * (14.5 / 100);
TextBox4.Text = Convert.ToString(guna);
TextBox5.Text = (amm + guna).ToString();
float s =Convert.ToSingle(txttp.Text) + Convert.ToSingle(TextBox6.Text);
TextBox7.Text=s.ToString();
//float amman = (sl+ float.Parse(TextBox6.Text));
//TextBox7.Text = Convert.ToString(amman);
}
protected void TextBox4_TextChanged(object sender, EventArgs e)
{
float sgs = int.Parse(TextBox3.Text) + int.Parse(TextBox4.Text);
TextBox5.Text = Convert.ToString(sgs);
}
protected void TextBox6_TextChanged(object sender, EventArgs e)
{
double value1 = Convert.ToDouble(txttp.Text);
double v2 = Convert.ToDouble(TextBox6.Text);
double t = value1 + v2;
TextBox7.Text = Convert.ToString(t);
}
protected void TextBox3_TextChanged(object sender, EventArgs e)
{
}
protected void Button3_Click(object sender, EventArgs e)
{
Response.Redirect("~/Admin/cementreport1.aspx");
}
}
it throw error like this
Subquery returned more than 1 value. This is not permitted when the subquery follows =, !=, <, <= , >, >= or when the subquery is used as an expression.
My procedure is
USE [Agri]
GO
/****** Object: StoredProcedure [dbo].[im] Script Date: 09/17/2013 14:35:05 ******/
SET ANSI_NULLS ON
GO
SET QUOTED_IDENTIFIER ON
GO
ALTER PROCEDURE [dbo].[im]
(@Product varchar(15),@Date varchar(50) ,@BillNo varchar(30) ,
@CustomerName varchar(50),@Address varchar(50) ,
@BrandName varchar(50) ,@Quantity varchar(20),
@ProductPrice varchar(20) ,@Requiredno varchar(50),
@Price varchar(50),@Extra varchar(20) ,
@Vat varchar(50),@TotalAmount varchar(50),
@CorrectPrice varchar(50),@type varchar(10)
)
AS
BEGIN
insert into sampl (ProductName,Date,BillNo,CustomerName,Address,BrandName,
Quantity,ProductPrice,Requiredno,Price,Vat,TotalAmount,type)
values(@Product,@Date,@BillNo ,@CustomerName ,@Address ,@BrandName ,
@Quantity ,@ProductPrice ,@Requiredno ,@Price ,@Vat ,@TotalAmount,@type);
insert into samle (ProductName,Date,BillNo,CustomerName,Address,BrandName,
Quantity,ProductPrice,Requiredno,Price,Extra,Vat,CorrectPrice) values
(@Product ,@Date,@BillNo ,@CustomerName ,@Address ,@BrandName ,@Quantity ,
@ProductPrice ,@Requiredno ,@Price ,@Extra ,
@Vat,@CorrectPrice );
if @type='s'
begin
declare @purno int
set @purno=(select purno from pr where brandname=@brandname)
declare @Reqno int
set @reqno=(select requiredno from sampl where brandname=@brandname)
update pr set purno=@purno-@Reqno where BrandName=@BrandName
end
END
Reply
Answers (
1
)
static website(html) to dynamic website in asp.net
what is linq?