C#C
C#3y ago
u41c

✅ Stored Procedure Help

Hello, I have a stored procedure in my project called spGetVendor. It takes one parameter, @VendorID. I've instantiated a new SqlCommand object that can be used to interact with the stored procedure and I've passed the parameter to it. When I try to use it however, it says that the parameter has not been passed?? Any ideas?

        public static Vendor GetVendor(int vendorID)
        {
            Vendor vendor = new Vendor();
            SqlConnection connection = PayablesDB.GetConnection();
            //string selectStatement =
             //   "SELECT VendorID, Name, Address1, Address2, City, State, " +
             //       "ZipCode, Phone, ContactFName, ContactLName, " +
             //       "DefaultAccountNo, DefaultTermsID " +
             //   "FROM Vendors " +
             //   "WHERE VendorID = @VendorID";
            SqlCommand selectCommand = new SqlCommand("spGetVendor", connection);
            selectCommand.Parameters.AddWithValue("@VendorID", vendorID);
Was this page helpful?