Click here to Skip to main content
15,893,588 members

How to Insert data in to database using three tier architecture?

raxhemanth asked:

Open original thread
Sir

My name is hemanth fresher learnig microsoft asp.net.
i have a doubt
here my intention is to insert data into database using 3tier architecture and display that in a grid view in the same page.
in my frontend i have admission no,gender,student name,mobilenumber fields.

i have added the dal and write the code like

namespace Dal
{
public class clsdataaccesslayer
{
SqlConnection Con = new SqlConnection(ConfigurationManager.ConnectionStrings["Connection"].ToString());
private void Registration()
{
SqlCommand Cmd = new SqlCommand("dbo.Sp_Registration", Con);
Con.Open();
Cmd.CommandType = CommandType.StoredProcedure;
try
{
Cmd.Parameters.AddWithValue("@P1",TextBox)
// Here How to add the parameters?
}

and in my business access layer i hage written the code like
C#
using Dal;
using System.Data;
namespace Bal
{
    public class Businessaccesslayer
    {
       int Adno;
       string Sname, Gender, Mno;
       clsdataaccesslayer objdal = new clsdataaccesslayer();
       public int PAdno
       {
           set { Adno = value; }
           get { return Adno; }
       }
       public string PSname
       {
           set { Sname = value; }
           get { return Sname; }
       }
       public string PGender
       {
           set { Gender = value; }
           get { return Gender; }
       }
       public string PMno
       {
           set { Mno = value; }
           get { return Mno; }
       }

     }

Please Help me out
Thanks and Regards
Tags: C#, ASP.NET, SQL Server

Plain Text
ASM
ASP
ASP.NET
BASIC
BAT
C#
C++
COBOL
CoffeeScript
CSS
Dart
dbase
F#
FORTRAN
HTML
Java
Javascript
Kotlin
Lua
MIDL
MSIL
ObjectiveC
Pascal
PERL
PHP
PowerShell
Python
Razor
Ruby
Scala
Shell
SLN
SQL
Swift
T4
Terminal
TypeScript
VB
VBScript
XML
YAML

Preview



When answering a question please:
  1. Read the question carefully.
  2. Understand that English isn't everyone's first language so be lenient of bad spelling and grammar.
  3. If a question is poorly phrased then either ask for clarification, ignore it, or edit the question and fix the problem. Insults are not welcome.
  4. Don't tell someone to read the manual. Chances are they have and don't get it. Provide an answer or move on to the next question.
Let's work to help developers, not make them feel stupid.
Please note that all posts will be submitted under the http://www.codeproject.com/info/cpol10.aspx.



CodeProject, 20 Bay Street, 11th Floor Toronto, Ontario, Canada M5J 2N8 +1 (416) 849-8900