如何在asp.net中使用System.data.common调用存储过程 [英] how to call stored procedure using System.data.common in asp.net

查看:108
本文介绍了如何在asp.net中使用System.data.common调用存储过程的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我有一个存储过程,用于插入,更新和三个数据库(sqlserver,mysql,oracle)和im使用system.data.common ..so如何调用存储过程???

i have a stored procedure for insert,update and three database(sqlserver,mysql,oracle) and i m using system.data.common ..so how to call stored procedure???

推荐答案

using System;
using System.Collections.Generic;
using System.Data;
using System.Data.Common;
using System.Data.SqlClient;
using System.Text;
using Microsoft.Practices.EnterpriseLibrary.Data.Sql;

// ...

SqlDatabase db = new SqlDatabase("YourConnectionString");
DbCommand cmd = db.GetStoredProcCommand("YourProcName");
cmd.Parameters.Add(new SqlParameter("YourParamName", "param value"));

using (IDataReader dr = db.ExecuteReader(cmd))
{
    while (dr.Read())
    {
        // do something with the data
    }
}


这篇关于如何在asp.net中使用System.data.common调用存储过程的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆