ghasem deh

ghasem deh

  • NA
  • 258
  • 37.6k

use stored procedure in 3 Tier ?

Apr 15 2015 11:20 AM
hi guy's ...
i want use stored procedure in 3-Tier for CRUD !
 
this procedure :
 
USE [RahgoshafanDB]GO
SET ANSI_NULLS ON
GO
SET QUOTED_IDENTIFIER ON
GO
CREATE PROCEDURE Category_Insert
@Category NVARCHAR(MAX),
@Toz NVARCHAR(MAX)
AS
BEGIN
INSERT INTO Category(Category, Toz)
VALUES (@Category, @Toz)
END
 
this data access layer :
 
using System;using System.Data;
using System.Data.SqlClient;
namespace DAL
{
public class Category_Dal
{
SqlConnection SqlCon = new SqlConnection("Data Source=.;Initial Catalog=RahgoshafanDB;Integrated Security=True");
int id;
public void Category_Insert()
{
try
{
SqlCommand cmd = new SqlCommand("Category_Insert", SqlCon);
cmd.CommandType = CommandType.StoredProcedure;
SqlCon.Open();
cmd.ExecuteNonQuery();
}
finally
{
if (SqlCon.State != ConnectionState.Closed)
SqlCon.Close();
}
}
}
}
 
butt now ... i not know write in BLL and Button_Insert  
please help ! 

Answers (3)