SOAP :
[WebMethod(Description = "Method to Delete User")]
public bool DeleteUser(string username)
{
bool returnBool = false;
SqlConnection dbConn = new SqlConnection(connStr);
string sqlStr = "DELETE FROM users where username = '" + username +"';";
SqlCommand dbCommand = new SqlCommand(sqlStr,dbConn);
try
{
dbConn.Open();
if (dbCommand.ExecuteNonQuery()!=0)
{
returnBool=true;
}
}
catch
{
returnBool=false;
}
dbConn.Close();
return returnBool;
}
WCF REST :
[OperationContract]
[WebInvoke(Method = "DELETE",
ResponseFormat = WebMessageFormat.Xml,
RequestFormat = WebMessageFormat.Xml,
BodyStyle = WebMessageBodyStyle.Bare,
UriTemplate = "usrdel/{user}")]
bool DeletePerson(string user);
public bool DeletePerson(string user)
{
bool returnBool = false;
SqlConnection dbConn = new SqlConnection(connStr);
string sqlStr = "DELETE FROM users where username = '" + user + "';";
SqlCommand dbCommand = new SqlCommand(sqlStr, dbConn);
try
{
dbConn.Open();
if (dbCommand.ExecuteNonQuery() != 0)
{
returnBool = true;
}
}
catch
{
returnBool = false;
}
dbConn.Close();
return returnBool;
}
No comments:
Post a Comment