nvarchar错误?

时间:2014-05-16 23:52:19

标签: sql vb.net

我已经创建了一个数据库,但是这个错误真让我烦恼,我已经尝试了所有技巧但它不断回来。它运行正常,但有时当我添加一行或从其中一个表中删除一个时它只是没有回到任何行但是当我把n放在dollarPrice之前它会再次没问题但是当我对表做出更改时再次发生错误然后我必须删除N它再次工作。它真的令人沮丧请任何帮助???代码如下......

Dim cmd As New SqlCommand("WITH tbl AS (SELECT ISNULL(SUM(CASE WHEN PayType = 2 AND CurrencyType = 1 THEN " +
"TotalPrice END), 0) AS [PurchaseTotalD]," +
"ISNULL(SUM(CASE WHEN PayType = 2 AND CurrencyType = 2 THEN " +
"TotalPrice / N'" & dollarPrice & "' END), 0) AS [PurchaseTotalID]," +
"(SELECT ISNULL(SUM(CASE WHEN CurrencyType = 1 THEN Amount END), 0) FROM PayCompany) AS [PayCompanyTotalD]," +
"(SELECT ISNULL(SUM(CASE WHEN CurrencyType = 2 THEN " +
"Amount / N'" & dollarPrice & "' END), 0) FROM PayCompany) AS [PayCompanyTotalID]," +
"(SELECT ISNULL(SUM(CASE WHEN CurrencyType = 1 THEN Amount END), 0) FROM Expenses) AS [ExpensesTotalD]," +
"(SELECT ISNULL(SUM(CASE WHEN CurrencyType = 2 THEN " +
"Amount / N'" & dollarPrice & "' END), 0) FROM Expenses) AS [ExpensesTotalID]," +
"(SELECT ISNULL(SUM(CASE WHEN PayType = 2 AND CurrencyType = 1 THEN TotalDiscount END), 0) FROM Cashier) AS [CashierTotalD]," +
"(SELECT ISNULL(SUM(CASE WHEN payType = 2 AND CurrencyType = 2 THEN " +
"TotalDiscount / N'" & dollarPrice & "' END), 0) FROM Cashier) AS [CashierTotalID]," +
"(SELECT ISNULL(SUM(CASE WHEN CurrencyType = 1 THEN Amount END), 0) FROM PayCashier) AS [PayCashierTotalD]," +
"(SELECT ISNULL(SUM(CASE WHEN CurrencyType = 2 THEN " +
"Amount / N'" & dollarPrice & "' END), 0) FROM PayCashier) AS [PayCashierTotalID]," +
"(SELECT ISNULL(SUM(CASE WHEN CurrencyType = 1 THEN PaidMoney END), 0) FROM Installments) AS [InstallmentsTotalD]," +
"(SELECT ISNULL(SUM(CASE WHEN CurrencyType = 2 THEN " +
"PaidMoney / N'" & dollarPrice & "' END), 0) FROM Installments) AS [InstallmentsTotalID] FROM Purchase)" +
"(SELECT (CashierTotalD + CashierTotalID + PayCashierTotalD + PayCashierTotalID + InstallmentsTotalD + InstallmentsTotalID) - " +
"(PurchaseTotalD + PurchaseTotalID +  PayCompanyTotalD + PayCompanyTotalID + ExpensesTotalD + ExpensesTotalID) AS [Purse] FROM tbl)", con)

    Dim da = New SqlDataAdapter(cmd11)
    Dim dt = New DataTable
    da.Fill(dt)
    PurseTB.Text = "$" & FormatNumber(dt.Rows(0).Item("Purse"), 3) 

0 个答案:

没有答案