如何在aspx.cs页面中编写视图创建的代码 [英] how to write the view created code in aspx.cs page

查看:117
本文介绍了如何在aspx.cs页面中编写视图创建的代码的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我在sql server中的查询如下

My query in sql server as follows

create view s as select distinct r.rate as Rate,f.bfid as BFid, CASE  
WHEN r.rate = '1' THEN 100 WHEN r.rate = '2' THEN 75 WHEN r.rate = '3' 
THEN 50 WHEN r.rate = '4' THEN 25 ELSE '0' END AS Translated_Rate FROM bthfac 
AS f,batch b,facfeedback r where  b.class = 'PST' and month(b.examdate)= 10 and  year(b.examdate)= 2011 and 
r.bfid=f.bfid and b.bthid=f.bthid and f.facid =  '60,75,6' 


select distinct avg(Rate) as rate, BFid, avg(Translated_Rate) 
                                         from s 
                                         group by bfid    

drop view s;



i创建了一个视图并删除了视图执行查询并成功。

在asp.net中,在aspx.cs页面中如何编写上面的sql查询代码



请帮帮我。



问候,

Narasiman P.


i created a view and drop the view execute the query and successful.
in the asp.net, in the aspx.cs page how can i write the above sql query code

please help me.

Regards,
Narasiman P.

推荐答案

使用普通的SqlCommand类执行相同的SQL,就像对任何其他SQL SELECT语句一样。网上有很多例子。
You execute that same SQL using the normal SqlCommand class, just like you do for any other SQL SELECT statement. There are tons of examples all over the web.


这篇关于如何在aspx.cs页面中编写视图创建的代码的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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