Mohd Aamir

Mohd Aamir

  • 1.8k
  • 66
  • 938

store procedure could not find

Oct 10 2018 4:27 AM
Hello ....!
 
I am getting an error plz help me to sort out it
 
Server Error in '/' Application.
Could not find stored procedure 'SELECT * from process WHERE pid = '49''.
Description: An unhandled exception occurred during the execution of the current web request. Please review the stack trace for more information about the error and where it originated in the code.
Exception Details: System.Data.SqlClient.SqlException: Could not find stored procedure 'SELECT * from process WHERE pid = '49''.
Source Error:
Line 41: cmd.CommandType = CommandType.StoredProcedure; Line 42: cmd.Parameters.AddWithValue("@pid", pid); Line 43: sqlDa.Fill(dt); Line 44: if (dt.Rows.Count > 0) Line 45: {
 
i want to display database value into labels
 
my asp.cs code is:-
 
  1. using System;  
  2. using System.Collections.Generic;  
  3. using System.Linq;  
  4. using System.Web;  
  5. using System.Web.UI;  
  6. using System.Web.UI.WebControls;  
  7. using System.Data;  
  8. using System.Data.SqlClient;  
  9. using System.Configuration;  
  10. public partial class admin_order : System.Web.UI.Page  
  11. {  
  12. SqlConnection con = new SqlConnection(ConfigurationManager.ConnectionStrings["DBCS"].ConnectionString);  
  13. protected void Page_Load(object sender, EventArgs e)  
  14. {  
  15. if (!IsPostBack)  
  16. {  
  17. MultiViewdo.SetActiveView(View1);  
  18. fill_grd1();  
  19. }  
  20. }  
  21. public void fill_grd1()  
  22. {  
  23. SqlCommand cmd = new SqlCommand("order1", con);  
  24. cmd.CommandType = CommandType.StoredProcedure;  
  25. SqlDataAdapter da = new SqlDataAdapter(cmd);  
  26. DataSet ds = new DataSet();  
  27. da.Fill(ds);  
  28. gv.DataSource = ds;  
  29. gv.DataBind();  
  30. }  
  31. public void getData()  
  32. {  
  33. string pid = ToString();  
  34. DataTable dt = new DataTable();  
  35. con.Open();  
  36. // SqlCommand sqlcmd = new SqlCommand("singleid", con);  
  37. SqlCommand cmd = new SqlCommand("SELECT * from process WHERE pid = '" + (gv.Rows[0].FindControl("lblidd"as Label).Text + "'", con);  
  38. SqlDataAdapter sqlDa = new SqlDataAdapter(cmd);  
  39. cmd.CommandType = CommandType.StoredProcedure;  
  40. cmd.Parameters.AddWithValue("@pid", pid);  
  41. sqlDa.Fill(dt);  
  42. if (dt.Rows.Count > 0)  
  43. {  
  44. lbldiscount.Text = dt.Rows[0]["discount"].ToString();  
  45. lblgrandtotal.Text = dt.Rows[0]["grandtotal"].ToString();  
  46. lblbuyername.Text = dt.Rows[0]["buyerName"].ToString();  
  47. lblbuyeremail.Text = dt.Rows[0]["buyerEmail"].ToString();  
  48. lblbuyermobileno.Text = dt.Rows[0]["buyerMobileNo"].ToString();  
  49. }  
  50. con.Close();  
  51. }  
  52. protected void gv_SelectedIndexChanged(object sender, EventArgs e)  
  53. {  
  54. }  
  55. protected void lbtn4deatail_Click(object sender, EventArgs e)  
  56. {  
  57. MultiViewdo.SetActiveView(Viewdo2);  
  58. int Index = ((GridViewRow)((sender as Control)).NamingContainer).RowIndex;  
  59. SqlDataAdapter da = new SqlDataAdapter("select * from process where pid = '" + (gv.Rows[Index].FindControl("lblidd"as Label).Text + "'", con);  
  60. DataSet ds = new DataSet();  
  61. da.Fill(ds);  
  62. grdvv.DataSource = ds.Tables[0];  
  63. grdvv.DataBind();  
  64. getData();  
  65. }  
  66. protected void Repeater2_ItemCommand(object source, RepeaterCommandEventArgs e)  
  67. {  
  68. }  
  69. protected void grdvv_SelectedIndexChanged(object sender, EventArgs e)  
  70. {  
  71. }  
  72. protected void Grd_SelectedIndexChanged(object sender, EventArgs e)  
  73. {  
  74. }  
  75. }  
aspx page
  1. <%@ Page Title="" Language="C#" MasterPageFile="~/admin/adminMasterPage.master" AutoEventWireup="true" CodeFile="order.aspx.cs" Inherits="admin_order" %>  
  2. <asp:Content ID="Content1" ContentPlaceHolderID="head" runat="Server">  
  3. </asp:Content>  
  4. <asp:Content ID="Content2" ContentPlaceHolderID="ContentPlaceHolder1" runat="Server">  
  5. <asp:MultiView ID="MultiViewdo" runat="server">  
  6. <asp:View ID="View1" runat="server">  
  7. <div style="width: 40%; float: left;">  
  8. <table>  
  9. <tr>  
  10. <td>  
  11. <asp:GridView ID="gv" runat="server" AutoGenerateColumns="false" OnSelectedIndexChanged="gv_SelectedIndexChanged">  
  12. <Columns>  
  13. <asp:TemplateField HeaderText="ID">  
  14. <ItemTemplate>  
  15. <asp:Label ID="lblidd" runat="server" Text='<%#Eval("pid")%>'></asp:Label></td></th>  
  16. </ItemTemplate>  
  17. </asp:TemplateField>  
  18. <asp:TemplateField HeaderText="Name">  
  19. <ItemTemplate>  
  20. <asp:Label ID="lblnamee" runat="server" Text='<%#Eval("buyerName")%>'></asp:Label></td></th>  
  21. </ItemTemplate>  
  22. </asp:TemplateField>  
  23. <asp:TemplateField HeaderText="Email">  
  24. <ItemTemplate>  
  25. <asp:Label ID="lblemaill" runat="server" Text='<%#Eval("buyerEmailId")%>'></asp:Label></td></th>  
  26. </ItemTemplate>  
  27. </asp:TemplateField>  
  28. <asp:TemplateField HeaderText="Mobile_No">  
  29. <ItemTemplate>  
  30. <asp:Label ID="lblmobileno" runat="server" Text='<%#Eval("buyerMobileNo")%>'></asp:Label></td></th>  
  31. </ItemTemplate>  
  32. </asp:TemplateField>  
  33. <asp:TemplateField HeaderText="Detail">  
  34. <ItemTemplate>  
  35. <asp:LinkButton ID="lbtn4deatail" runat="server" Text="More Detail" OnClick="lbtn4deatail_Click"></asp:LinkButton></td></th>  
  36. </ItemTemplate>  
  37. </asp:TemplateField>  
  38. </Columns>  
  39. </asp:GridView>  
  40. </td>  
  41. </tr>  
  42. </table>  
  43. </div>  
  44. </asp:View>  
  45. <asp:View ID="Viewdo2" runat="server">  
  46. <div>  
  47. <asp:GridView ID="grdvv" runat="server" AutoGenerateColumns="false" OnSelectedIndexChanged="grdvv_SelectedIndexChanged">  
  48. <Columns>  
  49. <asp:TemplateField HeaderText="ID">  
  50. <ItemTemplate>  
  51. <asp:Label ID="lblid" runat="server" Text='<%#Eval("processid")%>'></asp:Label></td></th>  
  52. </ItemTemplate>  
  53. </asp:TemplateField>  
  54. <asp:TemplateField HeaderText="PName">  
  55. <ItemTemplate>  
  56. <asp:Label ID="lblpname" runat="server" Text='<%#Eval("pname")%>'></asp:Label></td></th>  
  57. </ItemTemplate>  
  58. </asp:TemplateField>  
  59. <asp:TemplateField HeaderText="P_price">  
  60. <ItemTemplate>  
  61. <asp:Label ID="lbpprice" runat="server" Text='<%#Eval("pprice")%>'></asp:Label></td></th>  
  62. </ItemTemplate>  
  63. </asp:TemplateField>  
  64. <asp:TemplateField HeaderText="Quantity">  
  65. <ItemTemplate>  
  66. <asp:Label ID="lblquantity" runat="server" Text='<%#Eval("pquantity")%>'></asp:Label></td></th>  
  67. </ItemTemplate>  
  68. </asp:TemplateField>  
  69. </Columns>  
  70. </asp:GridView>  
  71. </div>  
  72. <br />  
  73. <br />  
  74. <br />  
  75. <h1>CheckOut Details</h1>  
  76. <div>  
  77. <strong>Discount(%): </strong>  
  78. <asp:Label ID="lbldiscount" runat="server"></asp:Label>  
  79. </div>  
  80. <div>  
  81. <strong>GrandTOtal: </strong>  
  82. <asp:Label ID="lblgrandtotal" runat="server"></asp:Label>  
  83. </div>  
  84. <div>  
  85. <strong>Buyer_Name: </strong>  
  86. <asp:Label ID="lblbuyername" runat="server"></asp:Label>  
  87. </div>  
  88. <div>  
  89. <strong>Buyer_Email: </strong>  
  90. <asp:Label ID="lblbuyeremail" runat="server"></asp:Label>  
  91. </div>  
  92. <div>  
  93. <strong>Buyer_MobileNo: </strong>  
  94. <asp:Label ID="lblbuyermobileno" runat="server"></asp:Label>  
  95. </div>  
  96. </asp:View>  
  97. </asp:MultiView>  
  98. </asp:Content>  
stored procedure is:-
  1. USE [addtocart28818]  
  2. GO  
  3. /****** Object: StoredProcedure [dbo].[singleid] Script Date: 10/10/2018 2:54:46 PM ******/  
  4. SET ANSI_NULLS ON  
  5. GO  
  6. SET QUOTED_IDENTIFIER ON  
  7. GO  
  8. ALTER proc [dbo].[singleid]  
  9. @pid int  
  10. as begin  
  11. select * from process where pid=@pid  
  12. end  
i want the single record at once after button click

Answers (5)