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
Mohd Aamir
NA
68
4.6k
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:-
using
System;
using
System.Collections.Generic;
using
System.Linq;
using
System.Web;
using
System.Web.UI;
using
System.Web.UI.WebControls;
using
System.Data;
using
System.Data.SqlClient;
using
System.Configuration;
public
partial
class
admin_order : System.Web.UI.Page
{
SqlConnection con =
new
SqlConnection(ConfigurationManager.ConnectionStrings[
"DBCS"
].ConnectionString);
protected
void
Page_Load(
object
sender, EventArgs e)
{
if
(!IsPostBack)
{
MultiViewdo.SetActiveView(View1);
fill_grd1();
}
}
public
void
fill_grd1()
{
SqlCommand cmd =
new
SqlCommand(
"order1"
, con);
cmd.CommandType = CommandType.StoredProcedure;
SqlDataAdapter da =
new
SqlDataAdapter(cmd);
DataSet ds =
new
DataSet();
da.Fill(ds);
gv.DataSource = ds;
gv.DataBind();
}
public
void
getData()
{
string
pid = ToString();
DataTable dt =
new
DataTable();
con.Open();
// SqlCommand sqlcmd = new SqlCommand("singleid", con);
SqlCommand cmd =
new
SqlCommand(
"SELECT * from process WHERE pid = '"
+ (gv.Rows[0].FindControl(
"lblidd"
)
as
Label).Text +
"'"
, con);
SqlDataAdapter sqlDa =
new
SqlDataAdapter(cmd);
cmd.CommandType = CommandType.StoredProcedure;
cmd.Parameters.AddWithValue(
"@pid"
, pid);
sqlDa.Fill(dt);
if
(dt.Rows.Count > 0)
{
lbldiscount.Text = dt.Rows[0][
"discount"
].ToString();
lblgrandtotal.Text = dt.Rows[0][
"grandtotal"
].ToString();
lblbuyername.Text = dt.Rows[0][
"buyerName"
].ToString();
lblbuyeremail.Text = dt.Rows[0][
"buyerEmail"
].ToString();
lblbuyermobileno.Text = dt.Rows[0][
"buyerMobileNo"
].ToString();
}
con.Close();
}
protected
void
gv_SelectedIndexChanged(
object
sender, EventArgs e)
{
}
protected
void
lbtn4deatail_Click(
object
sender, EventArgs e)
{
MultiViewdo.SetActiveView(Viewdo2);
int
Index = ((GridViewRow)((sender
as
Control)).NamingContainer).RowIndex;
SqlDataAdapter da =
new
SqlDataAdapter(
"select * from process where pid = '"
+ (gv.Rows[Index].FindControl(
"lblidd"
)
as
Label).Text +
"'"
, con);
DataSet ds =
new
DataSet();
da.Fill(ds);
grdvv.DataSource = ds.Tables[0];
grdvv.DataBind();
getData();
}
protected
void
Repeater2_ItemCommand(
object
source, RepeaterCommandEventArgs e)
{
}
protected
void
grdvv_SelectedIndexChanged(
object
sender, EventArgs e)
{
}
protected
void
Grd_SelectedIndexChanged(
object
sender, EventArgs e)
{
}
}
aspx page
<
%@ Page
Title
=
""
Language
=
"C#"
MasterPageFile
=
"~/admin/adminMasterPage.master"
AutoEventWireup
=
"true"
CodeFile
=
"order.aspx.cs"
Inherits
=
"admin_order"
%
>
<
asp:Content
ID
=
"Content1"
ContentPlaceHolderID
=
"head"
runat
=
"Server"
>
</
asp:Content
>
<
asp:Content
ID
=
"Content2"
ContentPlaceHolderID
=
"ContentPlaceHolder1"
runat
=
"Server"
>
<
asp:MultiView
ID
=
"MultiViewdo"
runat
=
"server"
>
<
asp:View
ID
=
"View1"
runat
=
"server"
>
<
div
style
=
"width: 40%; float: left;"
>
<
table
>
<
tr
>
<
td
>
<
asp:GridView
ID
=
"gv"
runat
=
"server"
AutoGenerateColumns
=
"false"
OnSelectedIndexChanged
=
"gv_SelectedIndexChanged"
>
<
Columns
>
<
asp:TemplateField
HeaderText
=
"ID"
>
<
ItemTemplate
>
<
asp:Label
ID
=
"lblidd"
runat
=
"server"
Text
=
'<%#Eval("pid")%>'
>
</
asp:Label
>
</
td
>
</
th
>
</
ItemTemplate
>
</
asp:TemplateField
>
<
asp:TemplateField
HeaderText
=
"Name"
>
<
ItemTemplate
>
<
asp:Label
ID
=
"lblnamee"
runat
=
"server"
Text
=
'<%#Eval("buyerName")%>'
>
</
asp:Label
>
</
td
>
</
th
>
</
ItemTemplate
>
</
asp:TemplateField
>
<
asp:TemplateField
HeaderText
=
"Email"
>
<
ItemTemplate
>
<
asp:Label
ID
=
"lblemaill"
runat
=
"server"
Text
=
'<%#Eval("buyerEmailId")%>'
>
</
asp:Label
>
</
td
>
</
th
>
</
ItemTemplate
>
</
asp:TemplateField
>
<
asp:TemplateField
HeaderText
=
"Mobile_No"
>
<
ItemTemplate
>
<
asp:Label
ID
=
"lblmobileno"
runat
=
"server"
Text
=
'<%#Eval("buyerMobileNo")%>'
>
</
asp:Label
>
</
td
>
</
th
>
</
ItemTemplate
>
</
asp:TemplateField
>
<
asp:TemplateField
HeaderText
=
"Detail"
>
<
ItemTemplate
>
<
asp:LinkButton
ID
=
"lbtn4deatail"
runat
=
"server"
Text
=
"More Detail"
OnClick
=
"lbtn4deatail_Click"
>
</
asp:LinkButton
>
</
td
>
</
th
>
</
ItemTemplate
>
</
asp:TemplateField
>
</
Columns
>
</
asp:GridView
>
</
td
>
</
tr
>
</
table
>
</
div
>
</
asp:View
>
<
asp:View
ID
=
"Viewdo2"
runat
=
"server"
>
<
div
>
<
asp:GridView
ID
=
"grdvv"
runat
=
"server"
AutoGenerateColumns
=
"false"
OnSelectedIndexChanged
=
"grdvv_SelectedIndexChanged"
>
<
Columns
>
<
asp:TemplateField
HeaderText
=
"ID"
>
<
ItemTemplate
>
<
asp:Label
ID
=
"lblid"
runat
=
"server"
Text
=
'<%#Eval("processid")%>'
>
</
asp:Label
>
</
td
>
</
th
>
</
ItemTemplate
>
</
asp:TemplateField
>
<
asp:TemplateField
HeaderText
=
"PName"
>
<
ItemTemplate
>
<
asp:Label
ID
=
"lblpname"
runat
=
"server"
Text
=
'<%#Eval("pname")%>'
>
</
asp:Label
>
</
td
>
</
th
>
</
ItemTemplate
>
</
asp:TemplateField
>
<
asp:TemplateField
HeaderText
=
"P_price"
>
<
ItemTemplate
>
<
asp:Label
ID
=
"lbpprice"
runat
=
"server"
Text
=
'<%#Eval("pprice")%>'
>
</
asp:Label
>
</
td
>
</
th
>
</
ItemTemplate
>
</
asp:TemplateField
>
<
asp:TemplateField
HeaderText
=
"Quantity"
>
<
ItemTemplate
>
<
asp:Label
ID
=
"lblquantity"
runat
=
"server"
Text
=
'<%#Eval("pquantity")%>'
>
</
asp:Label
>
</
td
>
</
th
>
</
ItemTemplate
>
</
asp:TemplateField
>
</
Columns
>
</
asp:GridView
>
</
div
>
<
br
/>
<
br
/>
<
br
/>
<
h1
>
CheckOut Details
</
h1
>
<
div
>
<
strong
>
Discount(%):
</
strong
>
<
asp:Label
ID
=
"lbldiscount"
runat
=
"server"
>
</
asp:Label
>
</
div
>
<
div
>
<
strong
>
GrandTOtal:
</
strong
>
<
asp:Label
ID
=
"lblgrandtotal"
runat
=
"server"
>
</
asp:Label
>
</
div
>
<
div
>
<
strong
>
Buyer_Name:
</
strong
>
<
asp:Label
ID
=
"lblbuyername"
runat
=
"server"
>
</
asp:Label
>
</
div
>
<
div
>
<
strong
>
Buyer_Email:
</
strong
>
<
asp:Label
ID
=
"lblbuyeremail"
runat
=
"server"
>
</
asp:Label
>
</
div
>
<
div
>
<
strong
>
Buyer_MobileNo:
</
strong
>
<
asp:Label
ID
=
"lblbuyermobileno"
runat
=
"server"
>
</
asp:Label
>
</
div
>
</
asp:View
>
</
asp:MultiView
>
</
asp:Content
>
stored procedure is:-
USE [addtocart28818]
GO
/****** Object: StoredProcedure [dbo].[singleid] Script
Date
: 10/10/2018 2:54:46 PM ******/
SET
ANSI_NULLS
ON
GO
SET
QUOTED_IDENTIFIER
ON
GO
ALTER
proc [dbo].[singleid]
@pid
int
as
begin
select
*
from
process
where
pid=@pid
end
i want the single record at once after button click
Reply
Answers (
5
)
How to convert Datatable to model list in MVC5
How wrong datatype deteriorates performance of C# app ?