// Collection of code snippets by Arne Vajhøj // (likely posted to comp.os.vms/INFO-VAX, INFO-TPU, MACRO32, eksperten.dk, newz.dk, LinkedIn or other place sometime between 1990 and now) using System; using System.Data; using System.Data.SqlClient; class MainClass { public static void Main(string[] args) { SqlConnection con = new SqlConnection("server=ARNEPC2;Integrated Security=SSPI;database=Test"); con.Open(); SqlCommand cmd = new SqlCommand("TEST_OUTRET", con); cmd.CommandType = CommandType.StoredProcedure; SqlParameter prm = new SqlParameter("@outarg", SqlDbType.Int, 0, "outarg"); prm.Direction = ParameterDirection.Output; cmd.Parameters.Add(prm); SqlParameter ret = new SqlParameter("@retval", SqlDbType.Int); ret.Direction = ParameterDirection.ReturnValue; cmd.Parameters.Add(ret); cmd.ExecuteNonQuery(); Console.WriteLine((int)cmd.Parameters["@outarg"].Value); Console.WriteLine((int)cmd.Parameters["@retval"].Value); con.Close(); } }