Quantcast
Channel: .NET Framework Class Libraries forum
Viewing all articles
Browse latest Browse all 8156

Stored procedure update

$
0
0

My stored procedure ( SQL 2012 )works fine from  SQL Server Management Studio.  However when I use C# with System.Data.SQLClient to invoke the stored procedure, no update takes place and no error is raised.

The C# Function is below - any ideas ?? 

 public int UpdateValuesbySP(string FunctionName, Hashtable theParams)
        {  
            int retVal=-1;
            SqlCommand command = new SqlCommand();

            if (staticSQLConn.State == ConnectionState.Closed)
            {
                staticSQLConn.Open();
            }
            // set command
            try
            {
                command.Connection = staticSQLConn;
                command.Parameters.Clear();
                if (theParams != null)
                {
                    foreach (DictionaryEntry item in theParams)
                    {
                        command.Parameters.AddWithValue(item.Key.ToString(), item.Value);
                    }
                }

                command.CommandType = CommandType.StoredProcedure;
                command.CommandText = FunctionName;
                retVal = command.ExecuteNonQuery();
              
            }

            catch (Exception e)
            {
                Console.WriteLine(e.Message);
            }
          
            return retVal;
        }


andrew


Viewing all articles
Browse latest Browse all 8156

Trending Articles



<script src="https://jsc.adskeeper.com/r/s/rssing.com.1596347.js" async> </script>