vb.net 关键字“DEFAULT”附近的语法不正确

声明:本页面是StackOverFlow热门问题的中英对照翻译,遵循CC BY-SA 4.0协议,如果您需要使用它,必须同样遵循CC BY-SA许可,注明原文地址和作者信息,同时你必须将它归于原作者(不是我):StackOverFlow 原文地址: http://stackoverflow.com/questions/23850633/
Warning: these are provided under cc-by-sa 4.0 license. You are free to use/share it, But you must attribute it to the original authors (not me): StackOverFlow

提示:将鼠标放在中文语句上可以显示对应的英文。显示中英文
时间:2020-09-17 17:36:18  来源:igfitidea点击:

Incorrect syntax near the keyword 'DEFAULT'

sql-servervb.netoledb

提问by Nur Ys

I have two Tables:

我有两个表:

1) Products: (productID pk; productName; productDesc; catID fk; serial; unitPrice; reOrderLevel;)

1) 产品:(productID pk;productName;productDesc;catID fk;serial;unitPrice;reOrderLevel;)

2) Transactions: (transID pk; trasDate; productID fk; purOrderID “purchase Order”; transDesc; unitsOrdered; unitsReceived;)

2)交易:(transID pk;trasDate;productID fk;purOrderID“采购订单”;transDesc;unitsOrdered;unitsReceived;)

In the vb.net Form (Purchase Orders) I need to show within a form Datagridview, all the products ordered by the selected Purchase Order.

在 vb.net 表单(采购订单)中,我需要在表单 Datagridview 中显示所选采购订单订购的所有产品。

So I have done the following SQL statement:

所以我做了以下SQL语句:

SELECT     transactions.transDate,
     products.productName,     
     transactions.unitsOrdered, 
     products.unitPrice
FROM         products INNER JOIN
     transactions ON products.productID =  transactions.ProductID
WHERE     (transactions.purOrderID = ?)

Of course the purchase order should be passed as parameter, and will be get from the textbox “txtOrderID”

当然采购订单应该作为参数传递,并且将从文本框“txtOrderID”中获取

I have a button “Order Details” that should show the Products purchased by single order which have the following Codes:

我有一个“订单详情”按钮,它应该显示通过单个订单购买的产品,这些产品具有以下代码:

      Me.DADetails.Fill(Me.DsDetails)

      Me.DADetails.SelectCommand.Parameters(0).Value = Me.txtOrderID.Text

When I run it and press on the Button Order Details I get the following error that point to the first line of code:

当我运行它并按下按钮订单详细信息时,我收到指向第一行代码的以下错误:

Title: OleDbException was unhandled

标题:OleDbException 未处理

Incorrect syntax near the keyword 'DEFAULT'.

Any Ideas ?

有任何想法吗 ?

采纳答案by Yuriy Galanter

The issue happens because parameter is not set when the query runs.

出现此问题是因为查询运行时未设置参数。

Firstassign the parameter value and thenrun the .Fillmethod. Switch order of those 2 lines of code

首先分配参数值,然后运行该.Fill方法。切换那两行代码的顺序