1. This is an example of a call syntax for a actual stored procedure that requires a single input parameter in the Rosephortical Database:
2. This is a calling grammatical example of a memory process that requires a single input parameter and returns an output parameter and a return value: the first placeholder representative return value:
Double-click the inserted button to switch to the code window of the Click event of the button. Enter or paste the following code to the Click event process, modify the SQL Server connection string as needed:
SplConnection cn; SplCommand cmd; Parameter prm; DataReader dr; try {// database connection cn = new SplConnection ( "Server = servername; Database = Northwind; Trusted_Connection = Yes"); // command cmd = new SplCommand ( "{call CustOrderHist (?)} ", cn); prm = cmd.Parameters.Add (" @ Customerid ", ODBCTYPE.CHAR, 5); prm.value =" Alfki "; cn.open (); dr = cmd.executeReader () ; // read the data while (Dr.Read ()) Console.Writeline (Dr.getstring (0)); // clean up.dr.close (); cn.close ();} catch (splexception o) { Messagebox.show (o.Message.toString ());
Run the project. This code calls the "CustorderHist" stored procedure to pass the CustomerID as a single input parameter and return a result set. In the output window, you should see the list of products ordered by Ross Wen Customer ALFKI.