Recently, many friends who are new to the sqldatasource control are attracted to its powerful functions and easy-to-use features.
However, while improving the ease of use, sqldatasource will inevitably lose some flexibility. Many friends are worried that the sqldatasource control parameters cannot use sqlparameter.
The parameter used by the sqldatasource control is parameter. This class function is much simpler than the sqlparameter class. There are only a few simple attributes, and we can only use parameter. defaultvalue is a string type attribute setting parameter, which is inconvenient.
In a project, a colleague wants to use sqldatasource to call SQL
Server Stored Procedures, and accept the output parameters of stored procedures. In the initial stage, it uses sqldatasource. selectparameter
["Mypara"]. The defaultvalue method tries to obtain data, but all of them fail. No suitable answer is found for searching online. after repeated attempts, the result is finally successful.
In the onselected event of the sqldatasource control, you can call the sqldatasourcestatuseventargs parameter to obtain the output parameter of the stored procedure,CodeAs follows:
Protected void sqldatasourceincluselected (Object sender, sqldatasourcestatuseventargs E)
{
Label1.text = E. Command. Parameters ["mypara"]. value. tostring ();
}
It is helpful for friends who need to call the response parameters using datasource!