retrieving values from sql server 2008 using asp

aio123ads

New Member
i getting values using sql union for two condition..while i am printing the result using asp..i am not getting the result.. this is my sql query\[code\]select P.[Port Name], CR.Name as country,CASEwhen SIH.[Ship-to Code] = '' then (select C.Name from [Customer] C where C.No_ = SIH.[Sell-to Customer No_])end as name,case when SIH.[Ship-to Code] = '' then (select C.Address from [Customer] C where C.No_ = SIH.[Sell-to Customer No_])end as addr, casewhen SIH.[Ship-to Code] = '' then (select C.[Address 2] from [Customer] C where C.No_ = SIH.[Sell-to Customer No_])end as addr2,casewhen SIH.[Ship-to Code] = '' then (select C.[Address 3] from [Customer] C where C.No_ = SIH.[Sell-to Customer No_])end as addr3,casewhen SIH.[Ship-to Code] = '' then (select C.[City] from [Customer] C where C.No_ = SIH.[Sell-to Customer No_])end as city,casewhen SIH.[Ship-to Code] = '' then (select C.[Post Code] from [Customer] C where C.No_ = SIH.[Sell-to Customer No_])end as pcode,casewhen SIH.[Ship-to Code] = '' then (select C.[Contact] from [Customer] C where C.No_ = SIH.[Sell-to Customer No_])end as cont,casewhen SIH.[Ship-to Code] = '' then (select C.[Phone No_] from [Customer] C where C.No_ = SIH.[Sell-to Customer No_])end as phno,casewhen SIH.[Ship-to Code] = '' then (select C.[E-Mail] from [Customer] C where C.No_ = SIH.[Sell-to Customer No_])end as email from [Sales Invoice Header] SIH, [Port] P, [Country_Region] CR where No_ = 'PEXP1213-546' and P.Code = SIH.Port and CR.Code = SIH.[Country of Final Destination] union all select P.[Port Name], CR.Name as country,casewhen SIH.[Ship-to Code] <> '' then (select C.Name from [Ship-to Address] C where C.Code = SIH.[Ship-to Code] and C.[Customer No_] = SIH.[Sell-to Customer No_])end as name,casewhen SIH.[Ship-to Code] <> '' then (select C.[Address] from [Ship-to Address] C where C.Code = SIH.[Ship-to Code] and C.[Customer No_] = SIH.[Sell-to Customer No_])end as addr,casewhen SIH.[Ship-to Code] <> '' then (select C.[Address 2] from [Ship-to Address] C where C.Code = SIH.[Ship-to Code] and C.[Customer No_] = SIH.[Sell-to Customer No_])end as addr2,casewhen SIH.[Ship-to Code] <> '' then (select C.[Address 3] from [Ship-to Address] C where C.Code = SIH.[Ship-to Code] and C.[Customer No_] = SIH.[Sell-to Customer No_])end as addr3,casewhen SIH.[Ship-to Code] <> '' then (select C.[City] from [Ship-to Address] C where C.Code = SIH.[Ship-to Code] and C.[Customer No_] = SIH.[Sell-to Customer No_])end as city,casewhen SIH.[Ship-to Code] <> '' then (select C.[Post Code] from [Ship-to Address] C where C.Code = SIH.[Ship-to Code] and C.[Customer No_] = SIH.[Sell-to Customer No_])end as pcode,casewhen SIH.[Ship-to Code] <> '' then (select C.[Contact] from [Ship-to Address] C where C.Code = SIH.[Ship-to Code] and C.[Customer No_] = SIH.[Sell-to Customer No_])end as cont,casewhen SIH.[Ship-to Code] <> '' then (select C.[Phone No_] from [Ship-to Address] C where C.Code = SIH.[Ship-to Code] and C.[Customer No_] = SIH.[Sell-to Customer No_])end as phno,casewhen SIH.[Ship-to Code] <> '' then (select C.[E-Mail] from [Ship-to Address] C where C.Code = SIH.[Ship-to Code] and C.[Customer No_] = SIH.[Sell-to Customer No_])end as email from [Sales Invoice Header] SIH, [Port] P, [Country_Region] CR where No_ = 'PEXP1213-546' and P.Code = SIH.Port and CR.Code = SIH.[Country of Final Destination]\[/code\]this is my asp code:\[code\]vwqry1 = "select P.[Port Name], CR.Name as country,CASE "_&" when SIH.[Ship-to Code] = '' then (select C.Name from [Customer] C where C.No_ = SIH.[Sell-to Customer No_]) "_&" end as name, "_&" case "_&" when SIH.[Ship-to Code] = '' then (select C.Address from [Customer] C where C.No_ = SIH.[Sell-to Customer No_]) "_&" end as addr, "_&" case "_&" when SIH.[Ship-to Code] = '' then (select C.[Address 2] from [Customer] C where C.No_ = SIH.[Sell-to Customer No_]) "_&" end as addr2, "_&" case "_&" when SIH.[Ship-to Code] = '' then (select C.[Address 3] from [Customer] C where C.No_ = SIH.[Sell-to Customer No_]) "_&" end as addr3, "_&" case "_&" when SIH.[Ship-to Code] = '' then (select C.[City] from [Customer] C where C.No_ = SIH.[Sell-to Customer No_]) "_&" end as city, "_&" case "_&" when SIH.[Ship-to Code] = '' then (select C.[Post Code] from [Customer] C where C.No_ = SIH.[Sell-to Customer No_]) "_&" end as pcode, "_&" case "_&" when SIH.[Ship-to Code] = '' then (select C.[Contact] from [Customer] C where C.No_ = SIH.[Sell-to Customer No_]) "_&" end as cont, "_&" case "_&" when SIH.[Ship-to Code] = '' then (select C.[Phone No_] from [Customer] C where C.No_ = SIH.[Sell-to Customer No_]) "_&" end as phno, "_&" case "_&" when SIH.[Ship-to Code] = '' then (select C.[E-Mail] from [Customer] C where C.No_ = SIH.[Sell-to Customer No_]) "_&" end as email "_&" from [Sales Invoice Header] SIH, [Port] P, [Country_Region] CR where No_ = '"& Request("invno_frm") &"' and P.Code = SIH.Port "_&" and CR.Code = SIH.[Country of Final Destination] "_&" union all "_&" select P.[Port Name], CR.Name as country, "_&"case "_&" when SIH.[Ship-to Code] <> '' then (select C.Name from [Ship-to Address] C where C.Code = SIH.[Ship-to Code] and "_&" C.[Customer No_] = SIH.[Sell-to Customer No_]) "_&" end as name, "_&" case "_&" when SIH.[Ship-to Code] <> '' then (select C.[Address] from [Ship-to Address] C where C.Code = SIH.[Ship-to Code] and "_&" C.[Customer No_] = SIH.[Sell-to Customer No_]) "_&" end as addr, "_&" case "_&" when SIH.[Ship-to Code] <> '' then (select C.[Address 2] from [Ship-to Address] C where C.Code = SIH.[Ship-to Code] and "_&" C.[Customer No_] = SIH.[Sell-to Customer No_]) "_&" end as addr2, "_&" case "_&" when SIH.[Ship-to Code] <> '' then (select C.[Address 3] from [Ship-to Address] C where C.Code = SIH.[Ship-to Code] and "_&" C.[Customer No_] = SIH.[Sell-to Customer No_]) "_&" end as addr3, "_&" case "_&" when SIH.[Ship-to Code] <> '' then (select C.[City] from [Ship-to Address] C where C.Code = SIH.[Ship-to Code] and "_&" C.[Customer No_] = SIH.[Sell-to Customer No_]) "_&" end as city, "_&" case "_&" when SIH.[Ship-to Code] <> '' then (select C.[Post Code] from [Ship-to Address] C where C.Code = SIH.[Ship-to Code] and "_&" C.[Customer No_] = SIH.[Sell-to Customer No_]) "_&" end as pcode, "_&" case "_&" when SIH.[Ship-to Code] <> '' then (select C.[Contact] from [Ship-to Address] C where C.Code = SIH.[Ship-to Code] and "_&" C.[Customer No_] = SIH.[Sell-to Customer No_]) "_&" end as cont, "_&" case "_&" when SIH.[Ship-to Code] <> '' then (select C.[Phone No_] from [Ship-to Address] C where C.Code = SIH.[Ship-to Code] and "_&" C.[Customer No_] = SIH.[Sell-to Customer No_]) "_&" end as phno, "_&" case "_&" when SIH.[Ship-to Code] <> '' then (select C.[E-Mail] from [Ship-to Address] C where C.Code = SIH.[Ship-to Code] and "_&" C.[Customer No_] = SIH.[Sell-to Customer No_]) "_&" end as email "_&" from [Sales Invoice Header] SIH, [Port] P, [Country_Region] CR where No_ = '"& Request("invno_frm") &"' and P.Code = SIH.Port "_&" and CR.Code = SIH.[Country of Final Destination]" rs.Open vwqry, conn rs1.Open vwqry1, conn\[/code\]when i run the sql query for one condition it gives the result..when i run this through web page i am not able to get the result
DKSfn.jpg
NxTps.jpg
 
Back
Top