我想在ASP.NET VB项目中显示案例的结果 [英] I want to display result of case when in ASP.NET VB project
本文介绍了我想在ASP.NET VB项目中显示案例的结果的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!
问题描述
我已经创建了一个商店程序,当我使用case语句和那种情况时,结果我必须显示输出
case
JobCardMst.CardTypeRefId = 435 然后 ' Field Job'
当 JobCardMst.CardTypeRefId = 436 然后 ' Workshop Job'
else ' < span class =code-string>作业类型其他' 结束
as ' 工作类型'
i希望将字段作业显示到标签或文本框中输出
我怎么样?
我尝试过的事情:
alter procedure prc_AllocatedUserInfo
@AllocatedToUser varchar (Max)
as
begin
声明 @ CardTypeRefId int = 0
选择 job.Id,job.CustClientLocID,
- JobCardMst.CardTypeRefId
- 作为作业类型
- ,
案例
JobCardMst.CardTypeRefId = 435 然后 ' Field Job'
何时 JobCardMst.CardTypeRefId = 436 然后 ' Workshop Job'
else ' 作业类型其他' 结束
as ' 作业类型'
来自作业 inner join JobCardMst on job.id = JobCardMst.JobId
inner join JobAllocation on JobAllocation.JobCardMstId = JobCardMst.Id
wh ere JobAllocation.AllocatedToUser = ' davell' @AllocatedToUser
end
公共 Sub load1()
Dim SqlCommand As 新 SqlClient.SqlCommand
Dim connection As String = ConfigurationManager.ConnectionStrings( strPROD)。ConnectionString
Dim con As 新 SqlConnection(连接)
SqlCommand.CommandText = prc_AllocatedUserInfo
SqlCommand.CommandTimeout = 0
SqlCommand.Connection = con
SqlCommand.CommandType = CommandType.StoredProcedure
Dim sqlDA 正如 新 SqlDataAdapter(SqlCommand)
SqlCommand.Parameters.Add( @ AllocatedToUser,SqlDbType.VarChar).Direction = ParameterDirection.Input
SqlCommand.Parameters( @ AllocatedToUser)。值=用户名
Dim ds As 新 DataSet()
sqlDA.Fill(ds)
' txt1.Text = ListView2.SelectedItems.Item(0).Text
joblistview1.DataSource = ds.Tables( 0 )
joblistview1.DataBind()
con。关闭()
结束 Sub
'txt1.Text = ListView2.SelectedItems(0).SubItems(2).Text
I have created a store procedure in that i used case when statement and that case when result i have to show output
case
when JobCardMst.CardTypeRefId =435 then 'Field Job'
when JobCardMst.CardTypeRefId =436 then 'Workshop Job'
else 'The Job Type Something else' end
as 'Job Type'
i want to display field job into label or textbox into output
how can i?
What I have tried:
alter procedure prc_AllocatedUserInfo
@AllocatedToUser varchar(Max)
as
begin
Declare @CardTypeRefId int=0
select job.Id, job.CustClientLocID,
-- JobCardMst.CardTypeRefId
--as 'Job Type'
--,
case
when JobCardMst.CardTypeRefId =435 then 'Field Job'
when JobCardMst.CardTypeRefId =436 then 'Workshop Job'
else 'The Job Type Something else' end
as 'Job Type'
from job inner join JobCardMst on job.id=JobCardMst.JobId
inner join JobAllocation on JobAllocation.JobCardMstId=JobCardMst.Id
where JobAllocation.AllocatedToUser = 'davell' @AllocatedToUser
end
Public Sub load1()
Dim SqlCommand As New SqlClient.SqlCommand
Dim connection As String = ConfigurationManager.ConnectionStrings("strPROD").ConnectionString
Dim con As New SqlConnection(connection)
SqlCommand.CommandText = "prc_AllocatedUserInfo"
SqlCommand.CommandTimeout = 0
SqlCommand.Connection = con
SqlCommand.CommandType = CommandType.StoredProcedure
Dim sqlDA As New SqlDataAdapter(SqlCommand)
SqlCommand.Parameters.Add("@AllocatedToUser", SqlDbType.VarChar).Direction = ParameterDirection.Input
SqlCommand.Parameters("@AllocatedToUser").Value = username
Dim ds As New DataSet()
sqlDA.Fill(ds)
'txt1.Text = ListView2.SelectedItems.Item(0).Text
joblistview1.DataSource = ds.Tables(0)
joblistview1.DataBind()
con.Close()
End Sub
解决方案
Try following:
'txt1.Text = ListView2.SelectedItems(0).SubItems(2).Text
这篇关于我想在ASP.NET VB项目中显示案例的结果的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!
查看全文