У меня есть запрос, который отлично работает в MSAccess, но когда я запускаю его в vb.net, я получаю следующее. Я мог бы понять, если бы это была вставка в таблицу, но это просто запрос на выборку, который затем выгружается в Excel в виде строковых значений.
Буду признателен за любые указания.
Сообщение об ошибке. System.Data.OleDb.OleDbException: "Точность десятичного поля слишком мала для принятия числа, которое вы попытались добавить".
code
и т. д.
Большое спасибо
Роб
'data
Dim Q1 As String = "SELECT [WARR INV1].invdate, [WARR INV1].yr, [WARR INV1].wk, [WARR INV1].Customer, [WARR INV1].InvoiceCustomerName AS Customer_Name, [warr Invoice 2].Charge, [warr Invoice 2].InvoiceLineTypeDes, [warr Invoice 2].InvoiceLineBasisDes, [warr Invoice 2].InvoiceLineQty, [warr Invoice 2].InvoiceLineRate, [warr Invoice 2].InvoiceLineTotal, [warr Invoice 2].InvoiceLineVATTot, [WARR INV1].InvoiceRef AS [Invoice No], [WARR INV1].InvoiceType, [dels grouped by week].SumOfloads AS receipts, [recpts grouped by week].SumOfplts AS [recpt plts], [recpts grouped by week].SumOfcases AS cases, [dels grouped by week].SumOfloads AS Deliveries, [dels grouped by week].SumOfplts AS [Del plts], [dels grouped by week].SumOfcases AS [Del Cases]" &
" FROM [Determine week] LEFT JOIN ((([WARR INV1] LEFT JOIN [warr Invoice 2] On [WARR INV1].InvoiceRef = [warr Invoice 2].InvoiceRef) LEFT JOIN [recpts grouped by week] On ([WARR INV1].yr = [recpts grouped by week].yr) And ([WARR INV1].wk = [recpts grouped by week].s) And ([WARR INV1].Customer = [recpts grouped by week].Customer)) LEFT JOIN [dels grouped by week] On ([WARR INV1].yr = [dels grouped by week].yr) And ([WARR INV1].wk = [dels grouped by week].WK) And ([WARR INV1].Customer = [dels grouped by week].Customer)) On [Determine week].wk = [WARR INV1].wk" &
" WHERE ((([WARR INV1].yr)='2024') AND (([WARR INV1].wk)='33') AND (([warr Invoice 2].InvoiceLineTypeDes) Is Not Null));"
osheet = oWB.Worksheets("Sheet1")
'CLEAR DATA
Dim rg = osheet.Range("a1:t1500")
rg.Clear()
y = 2
Dim cmd As New OleDbCommand(Q1, cnn)
Dim TheDataReader As OleDbDataReader = cmd.ExecuteReader() *' errors here*
osheet.Cells(1, 1) = "Invoice Date"
osheet.Cells(1, 2) = "Year"
osheet.Cells(1, 3) = "Customer"
osheet.Cells(1, 4) = "Customer Name"
osheet.Cells(1, 5) = "Charge"
osheet.Cells(1, 6) = "Invoice Sub-Type"
osheet.Cells(1, 7) = "Line Description"
osheet.Cells(1, 8) = "Invoice Ln Qty"
osheet.Cells(1, 9) = "Invoice Ln Rate"
osheet.Cells(1, 10) = "Invoice Ln Total"
osheet.Cells(1, 11) = "Invoice Ln VAT"
osheet.Cells(1, 12) = "Invoice Number"
osheet.Cells(1, 13) = "Invoice Type"
osheet.Cells(1, 14) = "Week"
osheet.Cells(1, 15) = "Receipts"
osheet.Cells(1, 16) = "Receipt Plts"
osheet.Cells(1, 17) = "Receipt Cases"
osheet.Cells(1, 18) = "Deliveries"
osheet.Cells(1, 19) = "Delivery Plts"
osheet.Cells(1, 20) = "Delivery Cases"
While TheDataReader.Read()
osheet.Cells(y, 1) = TheDataReader("Invdate").ToString()
osheet.Cells(y, 2) = TheDataReader("yr").ToString()
osheet.Cells(y, 3) = TheDataReader("customer").ToString()
Велимир
Вопрос задан16 января 2024 г.