在C#中将数据插入数据库 [英] inserting data into database in c#

查看:132
本文介绍了在C#中将数据插入数据库的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

大家好,


1)我在sqlserver-2008中创建了一个表emp(eno int主键,ename nvarchar,esal int).
2)我使用visualstudio2010打开了wcf服务模板
3)我使用LINQ向数据库添加了emp表到wcf服务.
(已声明的运营合同,服务合同...在这里一切都已完成/完好)

现在,我需要编写代码以将数据插入services.cs函数中的数据库中,作为InsertRecordintoDB

 公共  int  InsertRecordintoDB( int  eno,字符串 ename, int  esal)
{
EmployeeDataClassesDataContext db =  EmployeeDataClassesDataContext();

} 



以及它在客户端应用程序(wpf或asp.net)中的消耗方式.

任何身体都请帮助我
在此先感谢...................

解决方案

查看此链接,您可能会有所了解
在WCF中启用交易的6个步骤 [ ^ ]

hi all,


1)i created a table emp(eno int primary key,ename nvarchar,esal int) in sqlserver-2008.
2) i opened wcf service template using visualstudio2010
3)i added emp table to wcf service using LINQ to database.
(declared operation contract,service contract....here everything done/fine)

now i need to write code for to inserting the data into data base in the services.cs function as InsertRecordintoDB

public int InsertRecordintoDB(int eno ,string ename , int esal)
{
EmployeeDataClassesDataContext db = new EmployeeDataClassesDataContext();

}



and also how it is consuming in the client application(either wpf or asp.net).

any body please help to me
thanks in advance.............

解决方案

see this link you may get some idea
6 Steps to Enable Transactions in WCF[^]


这篇关于在C#中将数据插入数据库的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆