|
1. Call the stored procedure: Replace the string with the stored procedure name. string strSql = "proc_transfer"; 2. Set the sql script type: sqlComm.CommandType= CommandType.StoredProcedure; 3. Stored procedure with parameters: (the first two steps remain unchanged) (1) Define the parameter object to be passed into the stored procedure: SqlParameter SqlParametersqlPara = new SqlParameter("The name of the parameter in the stored procedure", The type of data in the database); sqlPara2.Value = outID; //putc #into the parameter object (2) to put the previous parameter object incommandGo inside sqlComm.Parameters.Add(sqlPara); (3The next step remains the same: letcommandexecute 4.Stored procedures with output parameters (1Than3(1One more sentence: set a property so that the object of the parameter becomes the output parameter sqlPara.Direction = ParameterDirection.Output; (2With3(2) is the same (3With3(3) is the same (4Get the output parameter: Get the value in the output parameter stringmess = sqlPara4.Value.ToString();
|