hi freds,
i alredy created stored proc. but i dnt knw How to call stored procedure in Business logic and Data Access layer?
please help me anyone......
Loading
Know the answer? Post it — somebody with the same question will find it here.
Sign in to answer this question
It is the same account you read, post and publish with — and you will come straight back to this page.
Satyapriya NayakPosted Mar 26, 2012, 9:58 AM
Stored procedure to display data
ALTER PROCEDURE display
AS
select * from student
<%@ Page Language="C#" AutoEventWireup="true" CodeBehind="Default.aspx.cs" Inherits="Stored_procedure_to_display._Default" %>
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 Stored_procedure_to_display
{
public partial class _Default : System.Web.UI.Page
{
string strConnString = ConfigurationManager.ConnectionStrings["ConnectionString"].ConnectionString;
SqlCommand com;
SqlDataAdapter sqlda;
DataSet ds;
protected void Page_Load(object sender, EventArgs e)
{
SqlConnection con = new SqlConnection(strConnString);
con.Open();
com = new SqlCommand("display", con);
com.CommandType = CommandType.StoredProcedure;
sqlda = new SqlDataAdapter(com);
ds = new DataSet();
sqlda.Fill(ds, "student");
GridView1.DataSource = ds;
GridView1.DataMember = "student";
GridView1.DataBind();
con.Close();
}
}
}
Thanks
If this post helps you mark it as answer
SenthilkumarPosted Mar 26, 2012, 5:15 AM
You can use the SqlCommand class to specify the type like Stored Procedure, Text, Table direct.
You can get more details on:
http://www.csharp-station.com/Tutorials/AdoDotNet/Lesson07.aspx
http://www.a2zdotnet.com/View.aspx?Id=20#.T3AzuMXxrdM