C# ExecuteNonQuery() sql语法错误 20

SqlCommandcomm=newSqlCommand(strSQl1,THDataBase.Conn);returncomm.ExecuteNonQuery();变量... SqlCommand comm = new SqlCommand(strSQl1, THDataBase.Conn);
return comm.ExecuteNonQuery();
变量comm没有问题. 主要是参数strSQl1.这个参数我是从txt文件中读出来的.是sql2000自动生成的.复制到查询分析器里也是没有问题的.但是ExecuteNonQuery();的时候就报错了看图!
sql语句也给上
if exists (select * from dbo.sysobjects where id = object_id(N'[dbo].[NFH]') and OBJECTPROPERTY(id, N'IsView') = 1)
drop view [dbo].[NFH]
GO

SET QUOTED_IDENTIFIER ON
GO
SET ANSI_NULLS ON
GO

CREATE VIEW dbo.NFH
AS
SELECT TOP 100 PERCENT dbo.fac_stuff_sett.sett_code AS ID,
dbo.fac_stuff_purchase.pur_code AS 磅单号,
dbo.fac_stuff_purchase.farmer_name AS 农户名,
dbo.base_farmer.farmer_tele AS 联系方式,
dbo.fac_stuff_purchase.measure_unit AS 单位,
dbo.fac_stuff_purchase.GW AS 毛重, dbo.fac_stuff_purchase.tare AS 重1,
dbo.fac_stuff_purchase.tare_time AS 时间, NULL AS 运量,
dbo.fac_stuff_purchase.NW AS 重2,
dbo.fac_stuff_purchase.ConvertLintWeight AS 重3,
dbo.fac_stuff_purchase.ConvertCSWeight AS 重4,
dbo.fac_stuff_purchase.pur_sum AS 金,
dbo.fac_stuff_purchase.QT_No AS 单号,
dbo.fac_stuff_purchase.MKLZ AS 值,
dbo.fac_stuff_purchase.stuff_grade AS 级,
dbo.fac_stuff_purchase.impurity_PC AS 率,
dbo.fac_stuff_purchase.moisture_PC AS 2率,
dbo.fac_stuff_purchase.LPC_M AS 1分,
dbo.fac_stuff_purchase.LPC_GD AS 2衣分, NULL AS 水分, NULL ASa率,
dbo.fac_stuff_purchase.BJ_sum AS r价, dbo.fac_stuff_sett.sett_code AS d单号,
dbo.fac_invoice.invoice_No AS 发票号, dbo.fac_invoice.pur_sum AS 金额,
dbo.fac_invoice.invoice_date AS 结算时间,
dbo.base_farmer.farmer_IDC AS 证号
FROM dbo.fac_invoice INNER JOIN
dbo.fac_stuff_purchase ON
dbo.fac_invoice.pur_code = dbo.fac_stuff_purchase.pur_code INNER JOIN
dbo.base_farmer ON
dbo.fac_stuff_purchase.farmer_code = dbo.base_farmer.farmer_code INNER JOIN
dbo.fac_stuff_sett ON
dbo.fac_stuff_purchase.pur_code = dbo.fac_stuff_sett.pur_code
ORDER BY dbo.fac_stuff_sett.sett_code

GO
SET QUOTED_IDENTIFIER OFF
GO
SET ANSI_NULLS ON
GO
展开
 我来答
xplong82
2012-03-10 · TA获得超过970个赞
知道小有建树答主
回答量:1058
采纳率:0%
帮助的人:940万
展开全部
//ExecuteNonQuery 为 Transaction 操作:

SqlTransaction tran = THDataBase.Conn.BeginTransaction();
SqlCommand comm = new SqlCommand(strSQl1, THDataBase.Conn, tran);
object result;
try
{
result = comm.ExecuteNonQuery();
}
catch{;;;} //自己catch
return result
// 你试试看
jeffhong99
2011-11-26 · TA获得超过200个赞
知道小有建树答主
回答量:524
采纳率:0%
帮助的人:319万
展开全部
你本来的sql语句就有错了。
追问
哪里错了啊!?我把这个粘贴到查询分析器里都没有问题的!!!!!!
求解答
已赞过 已踩过<
你对这个回答的评价是?
评论 收起
收起 1条折叠回答
推荐律师服务: 若未解决您的问题,请您详细描述您的问题,通过百度律临进行免费专业咨询

为你推荐:

下载百度知道APP,抢鲜体验
使用百度知道APP,立即抢鲜体验。你的手机镜头里或许有别人想知道的答案。
扫描二维码下载
×

类别

我们会通过消息、邮箱等方式尽快将举报结果通知您。

说明

0/200

提交
取消

辅 助

模 式