小妹初学C#,我在SQL里建了一个存储过程,程序调用的时候查询结果都是错的,急死了!向大家请教请教!
我的存储过程如下:
set ANSI_NULLS ON
set QUOTED_IDENTIFIER ON
GO
ALTER procedure [dbo].[pr_psr3] @vessel nvarchar(25)
as
begin
SELECT distinct t_cvm_address_1.company_name, t_cvm_address_2.company_name AS Expr1, t_cvm_address3.company_name AS Expr2, eCargoData.dbo.t_oeh_hbl.hbl_no,
eCargoData.dbo.t_oem_master.master_bl_no, SMLRPT.dbo.f_so(eCargoData.dbo.t_oeh_hbl.hbl_no) AS Expr5, t_cvm_address4.company_name AS Expr4,
eCargoData.dbo.t_oem_master.vessel_name, eCargoData.dbo.t_oem_master.voyage_no, eCargoData.dbo.t_oem_master.ams_vessel_name, eCargoData.dbo.t_oem_master.ams_voyage_no,
eCargoData.dbo.t_oem_master.on_board_date, eCargoData.dbo.t_oem_master.loading_port, eCargoData.dbo.t_oem_master.eta_date, eCargoData.dbo.t_oeh_hbl.hbl_discharge_port,
eCargoData.dbo.t_oeh_hbl.place_of_delivery, eCargoData.dbo.t_oem_master.place_of_delivery AS Expr6,
CASE WHEN [eCargoData].[dbo].[t_oeh_hbl_container].[container_no] IS NULL THEN [t_oem_container_2].[container_no] ELSE [oem_container_1].[container_no] END AS Expr3,
CASE WHEN [eCargoData].[dbo].[t_oeh_hbl_container].[container_no] IS NULL THEN [t_oem_container_2].[container_type] ELSE [oem_container_1].[container_type] END AS Expr7,
CASE WHEN [eCargoData].[dbo].[t_oeh_hbl_container].[container_no] IS NULL THEN [t_oem_container_2].[container_seal_no] ELSE [oem_container_1].[container_seal_no] END AS Expr8,
CASE WHEN [eCargoData].[dbo].[t_oeh_hbl_container].[container_no] IS NULL THEN [t_oem_container_2].[piece_count] ELSE [oem_container_1].[piece_count] END AS Expr9,
CASE WHEN [eCargoData].[dbo].[t_oeh_hbl_container].[container_no] IS NULL THEN [t_oem_container_2].[weight_kg] ELSE [oem_container_1].[weight_kg] END AS Expr10,
CASE WHEN [eCargoData].[dbo].[t_oeh_hbl_container].[container_no] IS NULL THEN [t_oem_container_2].[cbm] ELSE [oem_container_1].[cbm] END AS Expr11,
CASE WHEN [eCargoData].[dbo].[t_oeh_hbl_container].[container_no] IS NULL THEN [t_oem_container_2].[freight_cost] ELSE [oem_container_1].[freight_cost] END AS Expr12
FROM eCargoData.dbo.t_oem_master_container AS t_oem_container_2 RIGHT OUTER JOIN
eCargoData.dbo.t_oem_master INNER JOIN
eCargoData.dbo.t_oeh_hbl ON eCargoData.dbo.t_oem_master.oem_master_id = eCargoData.dbo.t_oeh_hbl.oem_master_id ON
t_oem_container_2.oem_master_id = eCargoData.dbo.t_oem_master.oem_master_id LEFT OUTER JOIN
eCargoData.dbo.t_oem_master_container AS oem_container_1 RIGHT OUTER JOIN
eCargoData.dbo.t_oeh_hbl_container ON oem_container_1.oem_master_id = eCargoData.dbo.t_oeh_hbl_container.oem_master_id AND
oem_container_1.container_no = eCargoData.dbo.t_oeh_hbl_container.container_no ON
eCargoData.dbo.t_oeh_hbl.oeh_hbl_id = eCargoData.dbo.t_oeh_hbl_container.oeh_hbl_id LEFT OUTER JOIN
eCargoData.dbo.t_cvm_address AS t_cvm_address4 ON eCargoData.dbo.t_oem_master.carrier_id = t_cvm_address4.cvm_address_id LEFT OUTER JOIN
eCargoData.dbo.t_cvm_address AS t_cvm_address3 ON eCargoData.dbo.t_oeh_hbl.shipper_id = t_cvm_address3.cvm_address_id LEFT OUTER JOIN
eCargoData.dbo.t_cvm_address AS t_cvm_address_1 ON eCargoData.dbo.t_oeh_hbl.consignee_id = t_cvm_address_1.cvm_address_id LEFT OUTER JOIN
eCargoData.dbo.t_cvm_address AS t_cvm_address_5 ON eCargoData.dbo.t_oem_master.agent_id = t_cvm_address_5.cvm_address_id LEFT OUTER JOIN
eCargoData.dbo.t_cvm_address AS t_cvm_address_2 ON eCargoData.dbo.t_oeh_hbl.notify_id = t_cvm_address_2.cvm_address_id
where (eCargoData.dbo.t_oem_master.vessel_name like '%'+@vessel+'%');
end
--------------------------------------------------------------------------------------------------
程序代码如下:
private void fillToolStripButton_Click(object sender, EventArgs e)
{
try
{
this.pr_psr3TableAdapter.Fill(this.sMLRPTDataSet.pr_psr3, vesselToolStripTextBox.Text);
}
catch (System.Exception ex)
{
System.Windows.Forms.MessageBox.Show(ex.Message);
}
}
我在SQL下执行我的存储过程查询出来的结果都是正确的,可是在C#下面就不行,我怀疑是数据类型不对,但不知道怎么办,小妹分少,望大侠别嫌弃,帮帮忙