首页 新闻 搜索 专区 学院

关于asp.net(C#)使用存储过程的应用?

0
[已关闭问题]

  想学习一下关于asp.net(C#)应用存储过程方面的知识,希望高手们给予指导啊!最好能附一些简单的例子,谢谢了!

luogao的主页 luogao | 初学一级 | 园豆:200
提问于:2009-12-10 15:02
< >
分享
其他回答(3)
0

OleDbParameter[] signParms = new OleDbParameter[] {
            new OleDbParameter(PARM_IN,OleDbType.VarChar ,50),//輸入參數
            new OleDbParameter(PARM_OUT , OleDbType.VarChar,100 )};//輸出參數
            signParms[0].Value = "";
            signParms[0].Direction = ParameterDirection.Input;
            signParms[1].Direction = ParameterDirection.Output;
            OracleHelper.ExecuteNonQuery(OracleHelper.ConnString, CommandType.StoredProcedure, PROCEDURE_NAME, signParms);

 

 

 

public static int ExecuteNonQuery(string connectionString, CommandType cmdType, string cmdText, params OleDbParameter[] commandParameters)
    {
        OleDbCommand cmd = new OleDbCommand();
        using (OleDbConnection connection = new OleDbConnection(connectionString))
        {
            PrepareCommand(cmd, connection, null, cmdType, cmdText, commandParameters);
            int val = cmd.ExecuteNonQuery();
            cmd.Parameters.Clear();
            return val;
        }
    }

 

 

 

  private static void PrepareCommand(OleDbCommand cmd, OleDbConnection conn, OleDbTransaction trans, CommandType cmdType, string cmdText, OleDbParameter[] commandParameters)
    {

        if (conn.State != ConnectionState.Open)
            conn.Open();
        cmd.Connection = conn;
        cmd.CommandText = cmdText;
        cmd.CommandType = cmdType;
        if (trans != null)
            cmd.Transaction = trans;
        if (commandParameters != null)
        {
            foreach (OleDbParameter parm in commandParameters)
                cmd.Parameters.Add(parm);
        }
    }

woody.wu | 园豆:3621 (老鸟四级) | 2009-12-10 15:19
0

楼上正解。

阿龍 | 园豆:268 (菜鸟二级) | 2009-12-10 16:54
0

SqlHelper是一个很好的封装应用实例

http://www.cnblogs.com/xiefang1980/archive/2008/03/10/1098938.html

http://www.51aspx.com/SqlHelper-1.html

http://www.cnblogs.com/eebb/archive/2007/04/10/706650.html

邀月 | 园豆:25375 (高人七级) | 2009-12-10 19:48
0

在数据库里学习其基本的语法,定义好存储过程,在VS里调用如楼1

YangLau | 园豆:313 (菜鸟二级) | 2009-12-17 11:28
清除回答草稿
   您需要登录以后才能回答,未注册用户请先注册