Hello, I am very new to C# and SQL. I have a small routine that imports an invoice from a text file, checks the size of the fields and then loads it to a table. This is all working fine, though I imagine looks very clumsy. I am now trying to add parameters to the code and I am now lost. Can someone please show me how to do this with the existing code or alternately send me down a better path altogether. This is also my first request for help, so advice on framing questions will also be appreciated.
Here is the stored Procedure:
ALTER PROCEDURE spSelectInvoice
@supplierID int
AS
SELECT * FROM tblSupplierInvoices WHERE fldSupplierID = @SupplierID
And this the part where I'm trying to get it to work, but after following multiple questions on various forums, I am now lost. How or where do I declare @supplierID as this fall over at da.fill(ds, "tblSupplierInvoices"); with the following error
Procedure or function 'spSelectInvoice' expects parameter '@supplierID', which was not supplied.
myConnection = sqlConnection;
string connectionString = myConnection.ConnectionString;
string commandString = "EXECUTE spSelectInvoice";
SqlDataAdapter da = new SqlDataAdapter(commandString, connectionString);
SqlCommandBuilder cb = new SqlCommandBuilder(da);
DataSet ds = new DataSet();
da.Fill(ds, "tblSupplierInvoices");
DataTable dt = ds.Tables["tblSupplierInvoices"];
da.FillSchema(dt, SchemaType.Source);