Click here to Skip to main content
15,881,600 members
Home / Discussions / Database
   

Database

 
QuestionStored Procedure execution from Entity Framework should return 0 or -1 if insert or update fails Pin
indian1437-Aug-18 14:27
indian1437-Aug-18 14:27 
AnswerRe: Stored Procedure execution from Entity Framework should return 0 or -1 if insert or update fails Pin
Mycroft Holmes7-Aug-18 14:37
professionalMycroft Holmes7-Aug-18 14:37 
GeneralRe: Stored Procedure execution from Entity Framework should return 0 or -1 if insert or update fails Pin
indian1437-Aug-18 14:39
indian1437-Aug-18 14:39 
GeneralRe: Stored Procedure execution from Entity Framework should return 0 or -1 if insert or update fails Pin
Mycroft Holmes7-Aug-18 16:38
professionalMycroft Holmes7-Aug-18 16:38 
GeneralRe: Stored Procedure execution from Entity Framework should return 0 or -1 if insert or update fails Pin
indian1438-Aug-18 6:38
indian1438-Aug-18 6:38 
GeneralRe: Stored Procedure execution from Entity Framework should return 0 or -1 if insert or update fails Pin
Richard Deeming8-Aug-18 0:27
mveRichard Deeming8-Aug-18 0:27 
GeneralRe: Stored Procedure execution from Entity Framework should return 0 or -1 if insert or update fails Pin
indian1438-Aug-18 6:42
indian1438-Aug-18 6:42 
GeneralRe: Stored Procedure execution from Entity Framework should return 0 or -1 if insert or update fails Pin
Richard Deeming8-Aug-18 8:23
mveRichard Deeming8-Aug-18 8:23 
Try something like this:
C#
public virtual int Usp_Add_LookupRecord(int? lookupTableId, string type, string description, int? foreignKeyId, string createdBy, string modifiedBy, bool? isValid)
{
    var returnValue = new SqlParameter
    {  
        ParameterName = "@ReturnValue",
        SqlDbType = SqlDbType.Int,
        Direction = System.Data.ParameterDirection.Output  
    };
    
    var lookupTableIdParameter = new SqlParameter("LookupTableId", SqlDbType.Int) 
    {
        Value = (object)lookupTableId ?? DBNull.Value
    };

    var typeParameter = new SqlParameter("Type", SqlDbType.VarChar, 100)
    {
        Value = (object)type ?? DBNull.Value
    };

    var descriptionParameter = new SqlParameter("Description", SqlDbType.VarChar, 500)
    {
        Value = (object)description ?? DBNull.Value
    };

    var foreignKeyIdParameter = new SqlParameter("ForeignKeyId", SqlDbType.Int)
    {
        Value = (object)foreignKeyId ?? DBNull.Value
    };

    var createdByParameter = new SqlParameter("CreatedBy", SqlDbType.VarChar, 500)
    {
        Value = (object)createdBy ?? DBNull.Value
    };

    var modifiedByParameter = new SqlParameter("ModifiedBy", SqlDbType.VarChar, 500)
    {
        Value = (object)modifiedBy ?? DBNull.Value
    };

    var isValidParameter = new SqlParameter("IsValid", SqlDbType.Bit)
    {
        Value = (object)isValid ?? DBNull.Value
    };
    
    Database.ExecuteSqlCommand("exec dbo.Usp_Add_LookupRecord", 
        returnValue, 
        lookupTableIdParameter, 
        typeParameter, 
        descriptionParameter, 
        foreignKeyIdParameter, 
        createdByParameter, 
        modifiedByParameter, 
        isValidParameter);

    return (int)returnValue.Value;
}




"These people looked deep within my soul and assigned me a number based on the order in which I joined."
- Homer

GeneralRe: Stored Procedure execution from Entity Framework should return 0 or -1 if insert or update fails Pin
indian1439-Aug-18 6:05
indian1439-Aug-18 6:05 
QuestionDATABASE Maintainance Pin
ricardobrooks6-Aug-18 3:12
ricardobrooks6-Aug-18 3:12 
AnswerRe: DATABASE Maintainance Pin
Victor Nijegorodov6-Aug-18 8:01
Victor Nijegorodov6-Aug-18 8:01 
AnswerRe: DATABASE Maintainance Pin
Eddy Vluggen6-Aug-18 8:15
professionalEddy Vluggen6-Aug-18 8:15 
GeneralRe: DATABASE Maintainance Pin
CHill606-Aug-18 22:01
mveCHill606-Aug-18 22:01 
Questionrecovery method for hard drive Pin
Member 139376004-Aug-18 4:08
Member 139376004-Aug-18 4:08 
AnswerRe: recovery method for hard drive Pin
Victor Nijegorodov4-Aug-18 20:34
Victor Nijegorodov4-Aug-18 20:34 
QuestionNeed to drop a schema in which there are some objects exist Pin
indian1431-Aug-18 6:28
indian1431-Aug-18 6:28 
AnswerRe: Need to drop a schema in which there are some objects exist Pin
Mycroft Holmes1-Aug-18 15:03
professionalMycroft Holmes1-Aug-18 15:03 
AnswerRe: Need to drop a schema in which there are some objects exist Pin
CHill602-Aug-18 2:26
mveCHill602-Aug-18 2:26 
QuestionRe: Need to drop a schema in which there are some objects exist Pin
CHill606-Aug-18 1:40
mveCHill606-Aug-18 1:40 
GeneralLegacy software: can't load MSJTER35.DLL Pin
Keith Sheppard227-Jul-18 23:26
Keith Sheppard227-Jul-18 23:26 
GeneralRe: Legacy software: can't load MSJTER35.DLL Pin
Victor Nijegorodov27-Jul-18 23:45
Victor Nijegorodov27-Jul-18 23:45 
GeneralRe: Legacy software: can't load MSJTER35.DLL Pin
Keith Sheppard22-Aug-18 1:23
Keith Sheppard22-Aug-18 1:23 
Questioninner join results Pin
Member 1386716325-Jul-18 18:12
Member 1386716325-Jul-18 18:12 
AnswerRe: inner join results Pin
Richard Deeming26-Jul-18 1:50
mveRichard Deeming26-Jul-18 1:50 
AnswerRe: inner join results Pin
Victor Nijegorodov26-Jul-18 1:54
Victor Nijegorodov26-Jul-18 1:54 

General General    News News    Suggestion Suggestion    Question Question    Bug Bug    Answer Answer    Joke Joke    Praise Praise    Rant Rant    Admin Admin   

Use Ctrl+Left/Right to switch messages, Ctrl+Up/Down to switch threads, Ctrl+Shift+Left/Right to switch pages.