数据
public int AddMessage(int moduleId, int fatherId, String userName, String title, String body, String face) {
if (userName.Length < 1) {
userName = "unknown";
}
// Create Instance of Connection and Command Object
SqlConnection myConnection = new SqlConnection(ConfigurationSettings.AppSettings["connectionString"]);
SqlCommand myCommand = new SqlCommand("up_PostTopic", myConnection);
// Mark the Command as a SPROC
myCommand.CommandType = CommandType.StoredProcedure;
// Add Parameters to SPROC
SqlParameter parameterItemID = new SqlParameter("@ItemID", SqlDbType.Int, 4);
parameterItemID.Direction = ParameterDirection.Output;
myCommand.Parameters.Add(parameterItemID);
SqlParameter parameterFatherId = new SqlParameter("@FatherID", SqlDbType.Int, 4);
parameterFatherId.Value = fatherId;
myCommand.Parameters.Add(parameterFatherId);
SqlParameter parameterModuleID = new SqlParameter("@ModuleID", SqlDbType.Int, 4);
parameterModuleID.Value = moduleId;
myCommand.Parameters.Add(parameterModuleID);
SqlParameter parameterUserName = new SqlParameter("@CreatedByUser", SqlDbType.NVarChar, 100);
parameterUserName.Value = userName;
myCommand.Parameters.Add(parameterUserName);
SqlParameter parameterTitle = new SqlParameter("@Title", SqlDbType.NVarChar, 100);
parameterTitle.Value = title;
myCommand.Parameters.Add(parameterTitle);
SqlParameter parameterBody = new SqlParameter("@Content", SqlDbType.NVarChar, 4000);
parameterBody.Value = body;
myCommand.Parameters.Add(parameterBody);
SqlParameter parameterFace = new SqlParameter("@Face", SqlDbType.NVarChar, 100);
parameterFace.Value = face;
myCommand.Parameters.Add(parameterFace);
myConnection.Open();
myCommand.ExecuteNonQuery();
myConnection.Close();
return (int) parameterItemID.Value;
}