PDA

View Full Version : مبتدی: سوال :استفاده از دستور case در select در function داخل class به زبان vb



sh.esma
دوشنبه 12 مرداد 1394, 09:30 صبح
سلام من میخوام این select رو در داخل function فرمم اضافه کنم

select top 100 [ID] , [Name], [Surname], [NatIDNo], [RegNo], [RegDate], [CommercialName], [City], [Province], [Address], [PostalCode], [GenDirCode], [Tel], [Mobile], [County], [RegistrationDate], [VatTaxNo],[LegalNatIDNo],[MainIDNo],
case type
when (1) then N'حقیقی'
when (2) then N'حقوقی'
end
as نوع
from tbltaxpayer

ولی وقتی همین طوری در فرم مینویسم اصلا type رو نمیخونه
cmdSelect.Parameters.Clear()
cmdSelect.CommandText = "select top 100 [ID],[type] ,[Name], [Surname], [NatIDNo], [RegNo], [RegDate], [CommercialName], [City], [Province], [Address], [PostalCode], [GenDirCode], [Tel], [Mobile], [County], [RegistrationDate], [VatTaxNo],[LegalNatIDNo],[MainIDNo],Case [Type] when (1) then N'حقیقی' when (2) then N'حقوقی' end as atype from tbltaxpayer"
Dim strWhere As String = " where "

sh.esma
دوشنبه 12 مرداد 1394, 14:05 عصر
سلام من میخوام این select رو در داخل function فرمم اضافه کنم

select top 100 [ID] , [Name], [Surname], [NatIDNo], [RegNo], [RegDate], [CommercialName], [City], [Province], [Address], [PostalCode], [GenDirCode], [Tel], [Mobile], [County], [RegistrationDate], [VatTaxNo],[LegalNatIDNo],[MainIDNo],
case type
when (1) then N'حقیقی'
when (2) then N'حقوقی'
end
as نوع
from tbltaxpayer

ولی وقتی همین طوری در فرم مینویسم اصلا type رو نمیخونه
cmdSelect.Parameters.Clear()
cmdSelect.CommandText = "select top 100 [ID],[type] ,[Name], [Surname], [NatIDNo], [RegNo], [RegDate], [CommercialName], [City], [Province], [Address], [PostalCode], [GenDirCode], [Tel], [Mobile], [County], [RegistrationDate], [VatTaxNo],[LegalNatIDNo],[MainIDNo],Case [Type] when (1) then N'حقیقی' when (2) then N'حقوقی' end as atype from tbltaxpayer"
Dim strWhere As String = " where "

خودم حلش کردم
select top 100 [ID] ,[Name], [Surname], [NatIDNo], [RegNo], [RegDate], [CommercialName], [City], [Province], [Address], [PostalCode], [GenDirCode], [Tel], [Mobile], [County], [RegistrationDate], [VatTaxNo],[LegalNatIDNo],[MainIDNo]," & _
" Case [type] when (1) then N'حقیقی' when (2) then N'حقوقی' End as N'نوع' " & _
"from tbltaxpayer"