如何使用STORED PROC [英] How to use STORED PROC

查看:76
本文介绍了如何使用STORED PROC的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

大家好,

我的WebForm中有一个dataGrid,我想使用
存储过程以填充DataGrid.

有人可以帮我吗. . .

非常感谢.

Hi All ,

i have one dataGrid in my WebForm and i want to use
a Stored Procedure to populate the DataGrid.

Can any one Help me please . . .

Many Thanks.

推荐答案


请参考以下链接

在ADO.NET中调用存储过程 [ C#Station ADO.NET教程 [在C#中调用存储过程 [ ^ ]
Hi,
Please refer below links

Calling Stored procedures in ADO.NET[^]
The C# Station ADO.NET Tutorial[^]
call stored procedure in C#[^]



检查此
Hi ,
Check this
//retrieve Data .
using (
                  SqlConnection con =
                      new SqlConnection(ConfigurationManager.ConnectionStrings["testConnectionString"].ConnectionString))
        {


            using (SqlCommand cmd = new SqlCommand("usp_test", con))
            {
                cmd.CommandType = CommandType.StoredProcedure;
                cmd.Parameters.AddWithValue("tst", txt.Text);
                DataTable dt = new DataTable();
                SqlDataAdapter adpt = new SqlDataAdapter(cmd);
                adpt.Fill(dt);
                GridView1.DataSource = dt;
                GridView1.DataBind();
            }
        }


在ADO.NET中调用存储过程 [ http://www.csharp-station.com/Tutorial/AdoDotNet/lesson07 [ ^ ]
http://www.c-sharpcorner.com /UploadFile/718fc8/saving-record-using-stored-procedure-in-ado-net/ [ http://msdn.microsoft.com/en-us/library/59x02y99.aspx [ ^ ]
最好的问候
M.Mitwalli


Calling Stored procedures in ADO.NET[^]
http://www.csharp-station.com/Tutorial/AdoDotNet/lesson07[^]
http://www.c-sharpcorner.com/UploadFile/718fc8/saving-record-using-stored-procedure-in-ado-net/[^]
http://msdn.microsoft.com/en-us/library/59x02y99.aspx[^]
Best Regards
M.Mitwalli




用这个

Hi,

Use this,

SqlCommand cmd=new SqlCommand("spGetData", con);
//con is your connection object.
SqlDataAdapter sda=new SqlDataAdapte(cmd) ;
DataTable dt=new DataTable();
sda.Fill(dt);
con.Close();
DataGrid1.DataSource=dt;
DataGrid1.DataBind();



这会为您提供帮助.
祝一切顺利.

-AK



This will help you.
All the best.

-AK


这篇关于如何使用STORED PROC的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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