English 中文(简体)
页: 1
原标题:ORDER BY giving wrong order

I have an SQL statement in my C# program that looks like:

SELECT * FROM XXX.dbo.XXX 
WHERE Source =  OH 
  AND partnum =  1231202085  
ORDER BY partnum, Packaging, Quantity

When running this query in SQL Server Management, the results are ordered as expected. My first 3 results have the same partnum and Packaging with Quantities of 32.0, 50.8, and 51.0.

然而,当我从我的节目中解答时,最初要退还的产值为50.8。 数量数据类型为少数(18.9)。 我曾尝试过,这似乎是一个数据类型的问题。

我很想知道,为什么要达到中间数量。


我在我的C#代码,而不是 s子中发现我的问题。

After getting the query results I hade:

if (PurchOrder.Read())
while (PurchOrder.Read())

如果看一看看看看一看我的第一个结果,那是谁却取得了我的第二个结果。

Ive replace the if statement with:

if (PurchOrder). HasRows=真实的

一切都看着罚款。

再次感谢您的回复。 处理误导问题。

- 同居

最佳回答

我在我的C#代码,而不是 s子中发现我的问题。

在获得询问结果之后,我说:

if (PurchOrder.Read()) while (PurchOrder.Read())

如果看一看看看看一看我的第一个结果,那是谁却取得了我的第二个结果。

兹将发言改为:

如果是(PurchOrder)。 HasRows=真实情况

and everything looks to fine.

再次感谢您的回复。 处理误导问题。

- 同居

问题回答

如果部分数字是甲型六氯环己烷,除非是你,否则不会按数字顺序分类。

  • 离开Pad partnum到完全相同的特性

  • Sort with some specialized alphanumeric sorting. I typically use:

    order by
    RIGHT(REPLICATE( 0 , 1000) + LTRIM(RTRIM(CAST([field_name] AS VARCHAR(8000)))), 1000)
    

当然,如果你的田地面积较小,你可以使用更低的dding号码。

From the SQL Server side as long as partnum, packaging, and quantity are a numeric/float field this should work absolutely fine. What worries me is if packaging or partnum is a text type variable where 10 comes before 2.

避免出现这种情况:<条码>。 在填写<代码>之前,数据类型为: 页: 1 http://msdn.microsoft.com/en-us/library/ms130214%28v=sql.90%29.aspx”rel=“nofollow”

例如:

CREATE TABLE #test
(
 mytest varchar(10)
)

INSERT INTO #test(mytest) VALUES( 10 )
INSERT INTO #test(mytest) VALUES( 1 )
INSERT INTO #test(mytest) VALUES( 2 )
INSERT INTO #test(mytest) VALUES( 12 )
INSERT INTO #test(mytest) VALUES( 20 )

SELECT * FROM #test ORDER BY mytest
DROP TABLE #test

产生不正确的订单。 也可以这样处理:

www.un.org/Depts/DGACM/index_french.htm

就客户而言(C#)你是否以某种电网方式储存了这种数据?





相关问题
Anyone feel like passing it forward?

I m the only developer in my company, and am getting along well as an autodidact, but I know I m missing out on the education one gets from working with and having code reviewed by more senior devs. ...

NSArray s, Primitive types and Boxing Oh My!

I m pretty new to the Objective-C world and I have a long history with .net/C# so naturally I m inclined to use my C# wits. Now here s the question: I feel really inclined to create some type of ...

C# Marshal / Pinvoke CBitmap?

I cannot figure out how to marshal a C++ CBitmap to a C# Bitmap or Image class. My import looks like this: [DllImport(@"test.dll", CharSet = CharSet.Unicode)] public static extern IntPtr ...

How to Use Ghostscript DLL to convert PDF to PDF/A

How to user GhostScript DLL to convert PDF to PDF/A. I know I kind of have to call the exported function of gsdll32.dll whose name is gsapi_init_with_args, but how do i pass the right arguments? BTW, ...

Linqy no matchy

Maybe it s something I m doing wrong. I m just learning Linq because I m bored. And so far so good. I made a little program and it basically just outputs all matches (foreach) into a label control. ...

热门标签