insert datas in database with 3 tier implementation??

Posted by Shailesh21235 under ASP.NET on 6/7/2012 | Points: 10 | Views : 1473 | Status : [Member] | Replies : 2
public DatabaseConnection()
{
string _constring = System.Configuration.ConfigurationManager.ConnectionStrings["data=PHP_TRAINEE2\\SQLEXPRESS"].ConnectionString;
SqlConnection _con = new SqlConnection(_constring);

}

IN the App_code folder i have added a new class DatabaseConnection and here i have to create a new function insertrecord which inserts the datas in database dbPersonDetail where columns are Name Age Email here and access it in .cs page???
how to implement sqlcommand in this function insertrecord ?? Any help with sample codes???




Responses

Posted by: Gow.Net on: 6/7/2012 [Member] Starter | Points: 25

Up
0
Down
refer this link
http://www.dotnetfunda.com/articles/article71.aspx

gowthaman8870226416

Shailesh21235, if this helps please login to Mark As Answer. | Alert Moderator

Posted by: Ajay.Kalol on: 6/7/2012 [Member] Starter | Points: 25

Up
0
Down
DAL

Public void insert(clsEntity obj)
{
SqlConnection con = new SQlConnection("Conn String");
SQlCommand cmd = new sqlCommand("SP Name",con);
cmd.CommandType = commandType.StoreProcedure;
cmd.parameters.addwithValue("@Param1",Obj.ID);
cmd.parameters.addwithValue("@Param2",Obj.Name);
con.open();
cmd.executeNonQuery();
con.close()
}

BAL

Public Void insert(clsEntity obj)
{
DAL objDAL = new DAL();
objDAL .insert(obj);
}

clsEntity
{
Public string ID { get; set;}
Public string Name { get; set;}
}

UI

Public Void InsertFun()
{
clsEntity objEntity = new clsEntity();
BAL objBAL = new objBAL();

objEntity .ID = "1";
objEntity .Name = "Ajay"

objBAL.insert(objEntity);

}


Ajay
ajaypatelfromsanthal.blogspot.in

Shailesh21235, if this helps please login to Mark As Answer. | Alert Moderator

Login to post response