how can insert data use teir 3 programming style without use store procedure

Posted by Umeshdwivedi under ASP.NET on 7/28/2011 | Points: 10 | Views : 846 | Status : [Member] | Replies : 1
Hall to all
any body give a exmple
insert data program in database
use teir 3 programming style,dont use store procedure
plsssssssssss help me .

Latest Technology Trainer
And Part time software consultant



Responses

Posted by: Hmanjarawala on: 8/4/2011 [Member] Bronze | Points: 25

Up
0
Down
Hi Umesh Hope this example will helps u:
DataAccessLayer

Class MyClass
{
public static int InsertData(MyBO bo)
{
string strQuery = "Insert into MyTable(a) Values('" + bo.A + "')";
SqlConnection con = new SqlConnection("<connection-string>");
con.Open();
SqlCommand com = new SqlCommand(strQuery,con);
com.CommandType = CommandType.Text;
com.ExecuteNonQuery();
}
}

BusinessObject

Class MyObject
{
public MyObject(){}
private string a
public string A
{
get{ return a;}
set{a=value;}
}
}

class MyObjectProcess
{
public static int InsertData(string strA)
{
MyObject obj = new MyObject();
obj.A = strA;
MyClass.InsertData(obj);
}
}

Application Layer

private btnAdd_Click(object sender, EventArgs e)
{
MyObjectProcess.InsertData(txtA.Text.Trim());
}

Himanshu Manjarawala
Sr. Software Engineer@AutomationAnywhere
http://fieredotnet.wordpress.com/

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

Login to post response