使用Wcf服务在数据库中插入数据 [英] inserting data in Database using Wcf Service

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

问题描述





我希望使用WCF服务将数据插入数据库。但我很困惑,当许多客户端例如250个客户端尝试使用该服务并同时将数据插入数据库时​​,它是否会起作用?我认为数据库可能会在某个时间点被锁定?如果是这样,那可能是什么解决方案。如果没有,为什么?如何处理?



谢谢。

Hi,

I wish to insert data into database using WCF service. But I am confused that whether it will work when many clients e.g 250 clients try consuming the service and inserting data into database at the same time? I think database may get locked at certain point of time? If that is so, What may be the solution to this. If not, why? How will it be handled?

Thanks.

推荐答案

以下是一些可以帮到你的链接决定如何处理WCF服务

: -

1。)http://www.sujitbhujbal.com/2012/10/wcf-example-for-inserting-and.html [ ^ ]



2.)http:// www.c-sharpcorner.com/UploadFile/rohatash/inserting-data-into-database-using-wcf-service/ [ ^ ]
Here are the some links which will help you to decide what to do with WCF service
:-
1.) http://www.sujitbhujbal.com/2012/10/wcf-example-for-inserting-and.html[^]

2.) http://www.c-sharpcorner.com/UploadFile/rohatash/inserting-data-into-database-using-wcf-service/[^]


< b> IDALService.cs

IDALService.cs
[OperationContract]
        bool functionname(int mID, string mName);





DALService.svc.cs



DALService.svc.cs

public bool functionname(int mID, string mName)
        {
            return mobjDal.functionname(mID, mName);
        }







DAL文件(Class.cs)

public bool functionname(int mID,string mName)

{

try

{

tblTable objTable = new tblTable(); // objTable是表中要添加记录的对象

objTable.ID = mID;

objTable.Name = mName;

mobjEntity.tblTable.AddObject(objTable); // mobjEntity是实体的对象

mobjEntity.SaveChanges();

返回true;

}

catch(例外mEx)

{

返回false;

}

}



请通过以下网址获取关于OperationContract的实施交易

在WCF中启用事务的6个步骤 [ ^ ]



希望这篇文章能帮到你..

问候,

Jitendra Kumar




DAL File(Class.cs)
public bool functionname(int mID, string mName)
{
try
{
tblTable objTable = new tblTable(); // objTable is object of table in which you want to add record
objTable.ID = mID;
objTable.Name = mName;
mobjEntity.tblTable.AddObject(objTable); // mobjEntity is the object of Entity
mobjEntity.SaveChanges();
return true;
}
catch(Exception mEx)
{
return false;
}
}

Please go through following url for implement Transaction on OperationContract
6 Steps to Enable Transactions in WCF[^]

Hope this post will help you..
Regards,
Jitendra Kumar


消费Wcf服务不是问题,我知道,但问题是,通过这个服务所有客户端将在同一时间点将数据插入数据库。这会产生问题吗?或者wcf服务自己管理它?如果可以在服务端管理,那么我需要做什么。?
Consuming of the Wcf service is not a problem, That i know, But The problem is that through this service all the clients will insert the data in to database at the same point of time. Will that create a problem? or the wcf service manages that at its own end? If That could be managed at the service end , Then what I need to DO.?


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

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