1 year ago

#380330

test-img

Prem

Calling a stored procedure throws an error "Cannot change thread mode after it is set"

I'm getting this error when calling a stored procedure from my C# code from BizTalk. Not sure whether this exception is thrown from the stored procedure or my own code, as it is in BizTalk runtime debugging is hard.

public bool ProcessDigiMarket (int marketID, long ProcessID, string processName)
{
    try
    {
        string storedProc = h.GetConfigValue(marketID, processName, "SP_GetDigiMarket");

        using (var conn = new SqlConnection(strcon))
        using (var cmd = conn.CreateCommand())
        {
            cmd.CommandTimeout = 0;
            cmd.CommandText = storedProc;
            cmd.CommandType = System.Data.CommandType.StoredProcedure;

            cmd.Parameters.AddWithValue("Mar_Id", marketID);
            cmd.Parameters.AddWithValue("ProcessID", ProcessID);

            conn.Open();
            cmd.ExecuteNonQuery();
            conn.Close();

            InsertLog("ExecuteSP for process -> " + processName + " -> Execution Complete : " + storedProc, marketID, ProcessID);
        }
    }
    catch(Exception ex)
    {
        InsertLog("ExecuteSP for Process -> " + processName + " -> Error while executing SPDigiMarketQueue: " + ex.Message, marketID, ProcessID);
        throw new Exception("Error while executing DigiMarket SP: SPDigiMarketQueue \n"+ex.Message);
    }

    return true;
}

c#

sql

sql-server

stored-procedures

biztalk

0 Answers

Your Answer

Accepted video resources