Your Stored Procedure is having the error that SubQuery return More then 1 row so you have to change the stored procedure with this:
ALTER procedure [storeinfo1]
-- [storeinfo1] 3333
@Behcode NVARCHAR(10)
AS
BEGIN
SELECT behcode,[name]
FROM House_Info
WHERE BehCode IN(SELECT behcode
FROM House_p
WHERE behcode = @Behcode)
END
HTML:
<form id="form1" runat="server">
<div>
Enter BehCode
<asp:TextBox ID="txtBehcode" runat="server" /><br />
<asp:Button Text="Search" OnClick="Populate" runat="server" />
<asp:Image ID="imgDemo" runat="server" Visible="false" ImageUrl="~/Images/Car.jpg" />
</div>
</form>
C#:
protected void Populate(object sender, EventArgs e)
{
this.Populate();
}
private void Populate()
{
string constr = ConfigurationManager.ConnectionStrings["ConString2"].ConnectionString;
using (SqlConnection _cn = new SqlConnection(constr))
{
using (SqlCommand _cmd = new SqlCommand("[storeinfo1]", _cn))
{
using (SqlDataAdapter da = new SqlDataAdapter(_cmd))
{
_cmd.CommandType = CommandType.StoredProcedure;
_cmd.Parameters.AddWithValue("@Behcode", this.txtBehcode.Text.Trim());
_cn.Open();
DataSet ds = new DataSet();
da.Fill(ds);
if (ds.Tables[0].Rows.Count == 0)
{
this.imgDemo.Visible = false;
}
else
{
this.imgDemo.Visible = true;
}
_cn.Close();
}
}
}
}
Thank You.