使用存储过程和3层标志进行网格视图绑定 [英] Grid View binding using Stored Procedure and flags in 3 tier

查看:76
本文介绍了使用存储过程和3层标志进行网格视图绑定的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

bal
public DataSet Fetch()
   {
       edal.connection();
       edal.sc.Open();
       ds = edal.Fill();
       edal.sc.Close();
       return ds;
   }

dal
public DataSet Fill()
    {
        SqlDataAdapter da = new SqlDataAdapter("masteriud", sc);
        da.SelectCommand.CommandType = CommandType.StoredProcedure;
        //SqlParameter param = new SqlParameter("@flag", 2);
        da.SelectCommand.Parameters.Add(new SqlParameter("@flag", SqlDbType.Int));
        da.SelectCommand.Parameters["@flag"].Value = 2;
        ds = new DataSet();
        da.Fill(ds);
        return ds;
    }
ui
    public void fill()
    {
        ds = ebal.Fetch();
        GridView1.DataSource = ds;
        GridView1.DataBind();
    }



错误-过程或函数``masteriud''需要未提供的参数``@Id''.

我不想使用任何参数,我只想使用flag
在页面加载时显示数据 我的存储过程是这样的



Error - Procedure or Function ''masteriud'' expects parameter ''@Id'', which was not supplied.

i dont want to use any parameter i just want to show data on page load using flag
my store procedure goes like this

alter procedure masteriud(@Id int,@Name varchar(50),@Address varchar(50),@flag int)
as
begin
if @flag='1'
begin
insert into Memployee(Id,Name,Address)values(@Id,@Name,@Address)
end

if @flag='2'
begin
select * from Memployee
end



请帮助我编写此编码
谢谢!!! :)



Please help me out in this coding
Thanks!!! :)

推荐答案

我不想使用任何参数,我只想使用标志在页面加载时显示数据
错误-过程或函数"masteriud"需要未提供的参数"@Id".
2件事:
1.传递所有4个参数以使其起作用-ID,名称,地址和地址.标记
2.或者,更改您的SP以仅根据您的期望获得1个参数标志,然后根据需要使用它来形成所需的查询.

试试吧!
i dont want to use any parameter i just want to show data on page load using flag
Error - Procedure or Function ''masteriud'' expects parameter ''@Id'', which was not supplied.
2 things:
1. Either pass on all the 4 parameters to make it work - Id, Name, Address & flag
2. Or, change your SP to just expect 1 parameter flag as per you want and then form the needed query just using it as you want to.

Try!


尊敬的Harsha,

您严重误解了分层的东西".在这里,您可以找到一个简单的示例,说明如何完成类似的操作.

http://www.wrox.com/WileyCDA/WroxTitle/productCd-0764584642,descCd- DOWNLOAD.html [ ^ ]
http://thebeerhouse.codeplex.com/ [ ^ ]
http://www.asp.net/web-forms/tutorials [
Dear Harsha,

you seriously misunderstood "the tier thing". Here you can find a simple example of how something similar can be done.

http://www.wrox.com/WileyCDA/WroxTitle/productCd-0764584642,descCd-DOWNLOAD.html[^]
http://thebeerhouse.codeplex.com/[^]
http://www.asp.net/web-forms/tutorials[^]

Check these pages out, you will find working examples which will help you understand the basic concepts and show you some nice tricks.


Cheers


您好,朋友,您正在通过代码在此过程中仅发送标志,让我们尝试一下
更改过程masteriud(@flag int)

开始
如果(@ flag == 1)
开始
插入Memployee(Id,Name,Address)值(@ Id,@ Name,@ Address)
结束

否则,如果(@ flag == 2)
开始
从Memployee中选择*
结束
结束
会起作用
hi friend you are sending only flag on this procedure through your code lets try this
alter procedure masteriud(@flag int)
as
begin
if (@flag==1)
begin
insert into Memployee(Id,Name,Address)values(@Id,@Name,@Address)
end

else if (@flag==2)
begin
select * from Memployee
end
end
it will work


这篇关于使用存储过程和3层标志进行网格视图绑定的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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