Click here to Skip to main content
15,886,032 members
Please Sign up or sign in to vote.
0.00/5 (No votes)
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.
Posted

 
Share this answer
 
IDALService.cs
C#
[OperationContract]
        bool functionname(int mID, string mName);


DALService.svc.cs
C#
public bool functionname(int mID, string mName)
        {
            return mobjDal.functionname(mID, mName);
        }



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
 
Share this answer
 
v2
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.?
 
Share this answer
 
v2
I think its better to handle this situation by using SQL Broker Service[^]
1: Insert Data in Broker Queue using WCF Service
2: Create a service that read Broker Queue periodically and Insert in to what ever you want. 
 
Share this answer
 
Comments
sudeep kushwaha 20-Mar-13 8:49am    
Is there any other Options? Actually i have never used SQL Server Service Broker.
 
Share this answer
 
i think that, there is no problem that how many users are consuming your WCF service at a time.
 
Share this answer
 
Comments
sudeep kushwaha 20-Mar-13 7:41am    
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.?

This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)



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