Question

This is my external procedure:

using (SqlConnection con = new SqlConnection("context conection=true"))
{
  SqlCommand cmd = new SqlCommand();
  cmd.Connection = con;
  if (con.State == ConnectionState.Closed)
  {
    con.Open();
  }
  cmd.CommandText = "INSERT ...";
  ...

  cmd.ExecuteNonQuery();
  cmd.Dispose();
  con.Close();
}

I have adding an assembly and the following procedure:

Create Proc usp_SaveFinanicalYear
(
  ... params
)
AS
  EXTERNAL NAME SqlLibrary.StoreProcedures.SaveFinanicalYear

When I call this procedure I get the following error (screen shot):

A .NET Framework error occurred during execution of user-defined routine or aggregate "usp_SaveFinanicalYear":
System.ArgumentException: Keyword not supported: 'context conection'.

Was it helpful?

Solution

You need to spell connection right. There are two ns.

using (SqlConnection con = new SqlConnection("context connection=true"))
                               //------------------------^

In any case, you shouldn't be using a CLR procedure for a simple INSERT. IMHO. This is like hiring a dump truck to get groceries.

Licensed under: CC-BY-SA with attribution
Not affiliated with StackOverflow
scroll top