views:

27

answers:

1

Newbie problem: I have a SQL SP with ten parameters (eight input, two output) but when I attempt to call it via LINQ from code I get the following error message:

"The best overloaded method match for 'DataClassesDataContext.ST_CR_CREATE_CASE_BASIS(string, string, string, string, System.DateTime?, string, string, string, ref int?, ref int?)' has some invalid arguments".

The params with ? appear to be unrecognized, but I'm baffled: the data types match the SQL types, the number of parameters match, the other parmeters don't exhibit the same behaviour. Can anyone tell me what's going on? Thanks in advance.

-- SQL SP:

create procedure ST_CR_CREATE_CASE_BASIS

@p_Pers_No      nvarchar (50),
@p_Subject      nvarchar (255),

@p_RQ_XML       nvarchar(max),
@p_RQ_XSL       nvarchar(max),
@p_Date_Submit      smalldatetime,
@p_User_ID_Submit   nvarchar (255),
@p_RQ_Status        nvarchar (50),
@p_User_ID_OnBehalf     nvarchar (255),

@p_Case_Number      int output,
@p_RQ_ID        int output

as
begin

 -- ... etc.; the SP works fine when called from SSMS

The code-behind proc from the aspx page looks like this:

protected void cmdSubmit_Click(object sender, EventArgs e)
{

    using (DataClassesDataContext vDataCont = new DataClassesDataContext())
    {
        Int32 vNewCaseNr;
        Int32 vNewReqNr;
        DateTime vNow = System.DateTime.Now;

        vDataCont.ST_CR_CREATE_CASE_BASIS("101", "Test Subject Late Wed", null, null, vNow , "101", "1", "101", ref vNewCaseNr, vNewReqNr);
     }

}
A: 
using (DataClassesDataContext vDataCont = new DataClassesDataContext())
    {
        int? vNewCaseNr;
        int? vNewReqNr;
        DateTime vNow = System.DateTime.Now;

        vDataCont.ST_CR_CREATE_CASE_BASIS("101", "Test Subject Late Wed", null, null, vNow , "101", "1", "101", ref vNewCaseNr, ref vNewReqNr);
     }
Raj Kaimal
Wonderful! This wasn't quite perfect, but it gave me enough to fix the problem.The actual fix is as per Raj's code above but initializing the variables: int? vNewCaseNr = 1; int? vNewReqNr = 1;...and then it works fine. Many thanks to everyone.
PaulC
Yes, of course, refs must be initialized. Typed too fast. :-(
Raj Kaimal