2013-10-17 70 views
-3

我清新,我创建一个存储过程对我的SQL表,我想显示这些数据输入到一个aspx页面..如何将存储过程值传递给webform?

我需要的代码for..ajax,JS,asp.net

+3

已经Google搜索吗?没有找到任何文章? –

+0

我尝试了几次我没有得到确切的代码 – RajeeshMenoth

+0

我不会提交这种类型的问题在这里谢谢你的反馈意见.. – RajeeshMenoth

回答

1

从我的头这样的顶部:

using (SqlConnection con = new SqlConnection(ConnectionString)) { 
    con.Open(); 
    using (SqlCommand command = new SqlCommand("ProcedureName", con)) { 
     command.CommandType = CommandType.StoredProcedure; 
     using(SqlReader reader = command.ExecuteReader()){ 
      if (reader.HasRows) { 
       while(reader.Read()) { 
        ... process SqlReader objects... 
       } 
      } 
     } 
    } 
} 

编辑:对不起,错过了“检索”信息。

+0

+1除了你可以离开'reader.HasRows'。如果它没有行,那么'reader.Read()'将返回false并且'while'循环将退出。 –

+0

同意,我曾经使用HasRows代码的一部分用于日志目的...有点坚持它,永远不会回去:-) – Gitzerai

相关问题