Here is my code
cmd.Connection = con;
if (con.State == ConnectionState.Closed)
{
con.Open();
}
cmd.CommandText = "Drop View [Picklist]";
cmd.ExecuteNonQuery();
cmd.CommandText = "CREATE VIEW [Picklist] AS select A.desp_no,A.desp_date,A.custid,A.comp_name,A.ref_no,B.item_code as itemid,B.Pqty,C.serial_no,C.batchno,C.expiry,D.Item_name,D.Item_code,D.Mrp,E.cust_name,E.Address1,E.Address2,E.Address3,E.Phone,E.Email from dbo.Tbl_DespDet A inner join dbo.Tbl_Desp_Sub B on A.desp_no=B.desp_no inner join dbo.tbl_desp_barcode C on c.desp_no=A.desp_no inner join tbl_itemMast D on D.item_id=B.item_code inner join dbo.tbl_CustMast E on A.custid=E.cust_id where A.desp_no=@despno";
cmd.Parameters.AddWithValue("@despno", beobj._Desno);
try
{
cmd.ExecuteNonQuery();
return true;
}
catch(Exception ex)
{
return false;
}
the same create view statement(with just copy paste) works in Sql Server Management Studio.Some one Help me as i am stuck in this Fix.
update:
the name of view is given as [Picklist] for testing only.even i have tried with removind square brackets and found no difference.
CREATE VIEW [Picklist] AS ... where A.desp_no=10. So the correct way is to create table valued function and passdesp_noas parameter. So could we mark it as duplicate or your case is different?