C# 在ASP.net的服务器端调用存储过程
我想调用Oracle存储过程,比如ASp.net中的“insert_into_pop”。。。。C# 在ASP.net的服务器端调用存储过程,c#,C#,我想调用Oracle存储过程,比如ASp.net中的“insert_into_pop”。。。。 如何将参数传递给它,以及如何在代码隐藏中调用它…?您可以这样做 using (OracleConnection connection = GetConnection) { OracleCommand command = new OracleCommand("insert_into_pop"); command.Connection = connection; command.Command
如何将参数传递给它,以及如何在代码隐藏中调用它…?您可以这样做
using (OracleConnection connection = GetConnection)
{
OracleCommand command = new OracleCommand("insert_into_pop");
command.Connection = connection;
command.CommandType = CommandType.StoredProcedure;
command.Parameters.AddWithValue("@Param", value); // 0 or more parameters passed in here
command.ExecuteNonQuery();
}
但无论如何,您不应该将其放在代码中,您应该有某种封装逻辑的服务或业务层。Craig-我按照问题中的要求添加了一个参数。希望它能让你再投一票或2票。。。