Home > Software design >  OledbDataReader getOrdinal Issue
OledbDataReader getOrdinal Issue

Time:08-26

I have some problem with the function GetOrdinal coming from the OleDb.DataReader. In my table, I have columns named with some space. I tried to call it with some [ ]:

Dim dr as System.Data.OleDb.OleDbDataReader dr.GetOrdinal("[Nom truc]")

but it's telling me : "IndexOutOfRangeException"

I can't change the name of the field. The type of my base is accdb. In Microsoft Access, my query is working.

Sorry for my poor english, I'm an France girl :)

Thank you in advance!

CodePudding user response:

You should remove the brackets:

'dr.GetOrdinal("[Nom truc]")
dr.GetOrdinal("Nom truc")
  • Related