vb.Net 里面 Run SQL语句是出现的问题,请教,
在vb.net里面,我从一个.sql的文件里面取出一个sql语句,如下:
if exists (select * from dbo.sysobjects where id = object_id(N'[dbo].[_OrganizationAgencyInfo]') and OBJECTPROPERTY(id, N'IsView') = 1)
drop view [dbo].[_OrganizationAgencyInfo]
GO
SET QUOTED_IDENTIFIER ON
GO
SET ANSI_NULLS ON
GO
CREATE VIEW dbo._OrganizationAgencyInfo
AS
SELECT dbo.Organization.Name AS Organization, dbo.Organization.OrgID, ActivityTemplate_2.Service AS ItemName,
ActivityTemplate_2.EligibilityDescriptionKey AS ItemKey, - 1 AS ParentKey, ActivityTemplate_2.ServiceType AS ItemType,
dbo.ApplicationMaster.ApplicationName
FROM dbo.Organization INNER JOIN
dbo.Agency ON dbo.Organization.Name = dbo.Agency.AgencyName INNER JOIN
dbo.ActivityTemplate ActivityTemplate_2 ON dbo.Agency.AgencyKey = ActivityTemplate_2.AgencyKey INNER JOIN
dbo.ApplicationMaster ON ActivityTemplate_2.AppID = dbo.ApplicationMaster.AppID
WHERE (ActivityTemplate_2.AgencyKey IN
(SELECT agencykey
FROM agency
WHERE external = 0)) AND (ActivityTemplate_2.ServiceType = N'Application')
UNION ALL
SELECT dbo.Organization.Name AS Organization, dbo.Organization.OrgID, ActivityTemplate_1.Service AS ItemName,
ActivityTemplate_1.EligibilityDescriptionKey AS ItemKey, ActivityTemplate_1.ApplicationCode AS ParentKey,
ActivityTemplate_1.ServiceType AS ItemType, '' AS ApplicationName
FROM dbo.Organization INNER JOIN
dbo.Agency ON dbo.Organization.Name = dbo.Agency.AgencyName INNER JOIN
dbo.ActivityTemplate ActivityTemplate_2 ON dbo.Agency.AgencyKey = ActivityTemplate_2.AgencyKey INNER JOIN
dbo.ActivityTemplate ActivityTemplate_1 ON ActivityTemplate_2.EligibilityDescriptionKey = ActivityTemplate_1.ApplicationCode
WHERE (ActivityTemplate_2.AgencyKey IN
(SELECT agencykey
FROM agency
WHERE external = 0)) AND (ActivityTemplate_1.ServiceType = N'Program')
UNION ALL
SELECT dbo.Organization.Name AS Organization, dbo.Organization.OrgID, ActivityTemplate_3.Service AS ItemName,
ActivityTemplate_3.EligibilityDescriptionKey AS ItemKey, ActivityTemplate_3.ApplicationCode AS ParentKey,
ActivityTemplate_3.ServiceType AS ItemType, '' AS ApplicationName
FROM dbo.Organization INNER JOIN
dbo.Agency ON dbo.Organization.Name = dbo.Agency.AgencyName INNER JOIN
dbo.ActivityTemplate ActivityTemplate_2 ON dbo.Agency.AgencyKey = ActivityTemplate_2.AgencyKey INNER JOIN
dbo.ActivityTemplate ActivityTemplate_1 ON ActivityTemplate_2.EligibilityDescriptionKey = ActivityTemplate_1.ApplicationCode INNER JOIN
dbo.ActivityTemplate ActivityTemplate_3 ON ActivityTemplate_1.EligibilityDescriptionKey = ActivityTemplate_3.ApplicationCode
WHERE (ActivityTemplate_2.AgencyKey IN
(SELECT agencykey
FROM agency
WHERE external = 0))
GO
SET QUOTED_IDENTIFIER OFF
GO
SET ANSI_NULLS ON
GO
该语句在查询分析器里执行没有错
在vb里面执行command时,提示如下错误:
Line 3: Incorrect syntax near 'GO'.
Line 6: Incorrect syntax near 'GO'.
Line 8: Incorrect syntax near 'GO'.
'CREATE VIEW' must be the first statement in a query batch.
Line 49: Incorrect syntax near 'GO'.
Line 51: Incorrect syntax near 'GO'.
Line 53: Incorrect syntax near 'GO'.
请问各位该怎么解决,谢谢