© 2026 Hedgehog Software, LLC

TwitterGitHubDiscord
More
CommunitiesDocsAboutTermsPrivacy
Search
Star
Setup for Free
C#C
C#•3y ago•
3 replies
u41c

✅ Stored Procedure Help

Hello, I have a stored procedure in my project called
spGetVendor
spGetVendor
. It takes one parameter,
@VendorID
@VendorID
. I've instantiated a new
SqlCommand
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);
        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);
C# banner
C#Join
We are a programming server aimed at coders discussing everything related to C# (CSharp) and .NET.
61,871Members
Resources

Similar Threads

Was this page helpful?
Recent Announcements

Similar Threads

❔ Dapper - Call stored procedure error
C#CC# / help
4y ago
❔ Csharp equivalent of JPA Stored Procedure Persistence
C#CC# / help
4y ago
❔ Passing a list of values to Stored Procedure in EF Core
C#CC# / help
4y ago