no value given for one or more required parameters in vb.net

I got this error

no value given for one or more required parameters

on this part of my code

Private Sub RefreshData()
    con.Open()

    cmd.CommandText = ("SELECT pCode as [ID], lampname as [NAME],  costumer, proddate, line/shift, watts, volts, filam, base, basepos,lumen, life, atm, fuse, exp, type,testCode, textVolt, samplesize, dateStart, timeStart, LNWatts1, LNWatts2, LNWatts3, LNWatts4, LNWatts5, LNLumen1, LNLumen2, LNLumen3, LNLumen4, LNLumen5, LPW1, LPW2, LPW3, LPW4, LPW5, RLWatts1, RLWatts2, RLWatts3, RLWatts4, RLWatts5, RLLumen1, RLLumen2, RLLumen3, RLLumen4, RLLumen5, LPWF1, LPWF2, LPWF3, LPWF4, LPWF5, InspectionTime1, InspectionTime2, InspectionTime3, InspectionTime4, InspectionTime5, InspectionDate1, InspectionDate2, InspectionDate3, InspectionDate4, InspectionDate5, TH1, TH2, TH3, TH4, TH5, EL1, EL2, EL3, EL4, EL5, Dispo1, Dispo2, Dispo3, Dispo4, Dispo5, CF1, CF2, CF3, CF4, CF5, Reason1, Reason2, Reason3, Reason4, Reason5, LNAve1, LNAve2, LNAve3, LNAve4, LNAve5, LNAve6, LNAve7, LNAve8, LNAve9, LNAve10, LNAve11, LNAve12, LNAve13, LNsd1, LNsd2, LNsd3, LNsd4, LNsd5, LNsd6, LNsd7, LNsd8, LNsd9, LNsd10, LNsd11, LNsd12, LNsd13, TorqueTest, zeroHour, EndOfLife, PFCPTime1, PFCPTime2, PFCPTime3, PFCPTime4, PFCPTime5, PFCPDate1, PFCPDate2, PFCPDate3, PFCPDate4, PFCPDate5, BatchNumber FROM records ORDER by ID")

    Dim da As New OleDbDataAdapter
    Dim dt As New DataTable

    da.SelectCommand = cmd
    da.Fill(dt)   -- I get the error right here

    con.Close()
End Sub

What would be the problem with that? Hoping for anyone to help, I'm just a newbie to vb.net..

thank you.

Upvotes: 0

Views: 1676

Answers (1)

LarsTech
LarsTech

Reputation: 81610

Try putting brackets around fields with the / character

proddate, [line/shift], watts, etc...

Otherwise, you have to painfully make sure every field you typed in your SQL string actually exists in the [records] table.

Given the number of fields in your query, I would think just doing SELECT * FROM [records] ORDER BY pCode would be good enough.

Also, make sure you use the real field name in the order clause:

ORDER BY pCode

Upvotes: 1

Related Questions