Exemplo n.º 1
0
        /// <summary>
        /// Calling Wrapper Stored Procedure's Parameters
        /// </summary>
        public void Example10()
        {
            // Create the connection
            SqlConnection conn =
                new SqlConnection("Server=localhost;" +
                                  "Database=ADONET;" +
                                  "Integrated Security=true;");

            conn.Open();

            // Create the stored procedure wrapper
            spAddMember sp = new spAddMember(conn);

            // Add the member variables
            sp.FirstName = "Greg";
            sp.LastName  = "Maddux";
            sp.Address   = "123 Main Street";
            sp.City      = "Atlanta";
            sp.State     = "GA";
            sp.Zip       = "30307";
            sp.Phone     = "404-555-1212";
            sp.Fax       = "404-555-1213";

            // Execute the stored procedure
            sp.Command.ExecuteNonQuery();

            // If the query worked, then get the key
            Int32 key;

            if (sp.RETURN_VALUE == 0)
            {
                key = sp.Key;
            }
        }
Exemplo n.º 2
0
        /// <summary>
        /// Using Stored Procedure Wrapper
        /// </summary>
        public void Example9()
        {
            // Create the connection
            SqlConnection conn =
                new SqlConnection("Server=localhost;" +
                                  "Database=ADONET;" +
                                  "Integrated Security=true;");

            conn.Open();

            // Create the stored procedure wrapper
            spAddMember sp = new spAddMember(conn);

            // Call the procedure
            sp.Execute("Maddux",
                       "Greg",
                       "123 Main Street",
                       "Atlanta",
                       "GA",
                       "30307",
                       "404-555-1212",
                       "404-555-1213");

            // If the query worked, then get the key
            Int32 key;

            if (sp.RETURN_VALUE == 0)
            {
                key = sp.Key;
            }
        }