Context
I am using Visual Studio 2013, and I have created an ADO.Net Entity Data Model which connect to my SQL Server 2014 database.
I can retrieve my data and display it using RESTful services.
Problem
But I can't insert a data into any table (delete and edit too).
Is my connection set to read-only mode? I looked to the properties of my DB but nothing points to that option.
Any help?!
Edited:
Here is my code of WCF Service. Below is Create()
body:
using (OnlinestoreEntities ose = new OnlinestoreEntities())
{
try
{
UserEntity user = new UserEntity();
user.Id = _user.Id;
user.Name = _user.Name;
user.Password = _user.Password;
user.Email = _user.Email;
ose.UserEntities.Add(user);
ose.SaveChanges();
return true;
}
catch
{
return false;
}
};
The following code is Create()
on the client side (using MVS model), this function is called from the controller when clicks in the Add User
link:
public bool Create(User user)
{
try
{
var webClient = new WebClient();
DataContractJsonSerializer ser = new DataContractJsonSerializer(typeof(User));
MemoryStream mem = new MemoryStream();
ser.WriteObject(mem, user);
string data = Encoding.UTF8.GetString(mem.ToArray(), 0, (int)mem.Length);
webClient.Headers["Content-type"] = "application/json";
webClient.Encoding = Encoding.UTF8;
String str = webClient.UploadString(BASE_URL + "create", "POST", data);
return true;
}
catch
{
return false;
}
}
Do you still need any details, I thought the problem was about DB settings?!