得到最新的收货价格 [英] get the latest receiving price
本文介绍了得到最新的收货价格的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!
问题描述
private void GetLastReceivingPrice()
{
sqlCon.Open();
strSQL = 从日期desc中选择从交货单接收的前1名,其中description = @ desc和剂量= @剂量跨度>;
SqlCommand cmd = new SqlCommand(strSQL,sqlCon);
cmd.Parameters.AddWithValue( @ desc,txtItemDescription.Text);
cmd.Parameters.AddWithValue( @ dosage,txtDosage.Text);
txtPrevious.Text = cmd.ExecuteScalar()。ToString();
sqlCon.Close();
}
错误是在关键词附近不正确的语法中
>
我在退货时退回供应商订单收到的最新价格
将在TXTPREVIOUS.TEXT显示
感谢提前
解决方案
我能看到两个你的代码中的问题:
1.正如 Wes Aday 所说,date
是一个保留字。把它放在方括号:[date]
。
2.ORDER BY
子句必须在WHERE
子句。
所以请尝试更改:
strSQL = 从日期desc中选择从交货订单接收的前1名,其中description = @ desc和剂量= @剂量;
这个:
strSQL = 选择从交付处收到的前1名,其中description = @desc和剂量= @dosage order by [date] desc;
您的SQL不正确。 by by 需要在where子句之后。
选择 top 1 接收
来自交付
其中 description = @ desc
和剂量= @剂量
订单 按 date desc
private void GetLastReceivingPrice()
{
sqlCon.Open();
strSQL = 选择从交货处收到的前1名,其中描述= @ desc和剂量= @剂量按日期排序desc;
SqlCommand cmd = new SqlCommand(strSQL,sqlCon);
cmd.Parameters.AddWithValue( @ desc,txtItemDescription.Text);
cmd.Parameters.AddWithValue( @ dosage,txtDosage.Text);
txtPrevious.Text = cmd.ExecuteScalar()。ToString();
sqlCon.Close();
}
JAFC
private void GetLastReceivingPrice()
{
sqlCon.Open();
strSQL = "select top 1 receiving from Delivery order by date desc where description=@desc and dosage=@dosage";
SqlCommand cmd = new SqlCommand(strSQL, sqlCon);
cmd.Parameters.AddWithValue("@desc", txtItemDescription.Text);
cmd.Parameters.AddWithValue("@dosage", txtDosage.Text);
txtPrevious.Text = cmd.ExecuteScalar().ToString();
sqlCon.Close();
}
ERROR IS " INCORRECT SYNTAX NEAR THE KEYWORD "WHERE"
I AM RETRIEVING THE LATEST PRICE RECEIVED FROM A SUPPLIER ORDER BY DATE DESCENDING
TO BE DISPLAYED IN TXTPREVIOUS.TEXT
THANKS IN ADVANCE
解决方案
Hi,
I can see two problems in your code:
1. As Wes Aday said,date
is a reserved word. Put it in the square brackets:[date]
.
2.ORDER BY
clause must be after theWHERE
clause.
So try changing this:
strSQL = "select top 1 receiving from Delivery order by date desc where description=@desc and dosage=@dosage";
with this:
strSQL = "select top 1 receiving from Delivery where description = @desc and dosage = @dosage order by [date] desc";
Your SQL is incorrect. The order by needs to be after the where clause.
select top 1 receiving from Delivery where description=@desc and dosage=@dosage order by date desc
private void GetLastReceivingPrice() { sqlCon.Open(); strSQL = "select top 1 receiving from Delivery where description=@desc and dosage=@dosage order by date desc "; SqlCommand cmd = new SqlCommand(strSQL, sqlCon); cmd.Parameters.AddWithValue("@desc", txtItemDescription.Text); cmd.Parameters.AddWithValue("@dosage", txtDosage.Text); txtPrevious.Text = cmd.ExecuteScalar().ToString(); sqlCon.Close(); }
JAFC
这篇关于得到最新的收货价格的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!
查看全文