如何将存储过程输出到gridview [英] how to output the stored procedure on to gridview

查看:94
本文介绍了如何将存储过程输出到gridview的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

DataTable dt = new DataTable();
            
//Open Connection
try
{
    string conHostName = "172.21.0.45";
    string conPort = "1522";
    string conDatabase = "ora11gv4";
    string _dbUserName = "ScibasePD";
    string _dbPwd = "ScibasePD";

    string conStr = string.Format("Data Source=(DESCRIPTION=(ADDRESS_LIST=(ADDRESS=(PROTOCOL=TCP)(HOST={0})(PORT={1})))(CONNECT_DATA=(SERVER=DEDICATED)(SERVICE_NAME={2})));User Id={3};Password={4};",
                     conHostName, conPort, conDatabase, _dbUserName, _dbPwd);

    OracleConnection con = new OracleConnection(conStr);
    con.Open();
    // define Command
    using (OracleCommand cmd = new OracleCommand())
    {
          //// create & define the parameter
          //var refCursorParam = new OracleParameter();
          //refCursorParam.ParameterName = "";
          //refCursorParam.OracleType = OracleType.Cursor;
          //refCursorParam.Direction = ParameterDirection.Output;
          
          cmd.Connection = con;
          cmd.CommandType = CommandType.StoredProcedure;
          cmd.CommandText = "REPORTS.GET_DAILY_STATUS";
                    
          //define the data adapter and fill the dataset
          using (OracleDataAdapter oda = new OracleDataAdapter(cmd))
          {
              oda.Fill(dt);
          }
     }
           bindingSource1.DataSource = dt;
}
catch (Exception ex)
{
     throw ex;
}

推荐答案

您缺少步骤
bindingSource1.DataBind();

休息
希望此链接对您有帮助:
http://stackoverflow.com/questions/6491159/c- Sharp-oracle-execute-stored-procedure-with-output-parameter [
You missing Step
bindingSource1.DataBind();

Rest
Hope this link Help you:
http://stackoverflow.com/questions/6491159/c-sharp-oracle-execute-stored-procedure-with-output-parameter[^]


这篇关于如何将存储过程输出到gridview的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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