Error creating database connection with field name "Section"

  • Thread starter Thread starter Dave
  • Start date Start date
D

Dave

I've run across a strange error when creating a simple ADO.Net
connection in VB.Net 2003

To replicate an error:
Create an Access database (2002) with table named "Student" and fields
SID (Autofill), FirstName and LastName.

Put some dummy data in table.

Start a new VB.Net application, create a new connection to your
database, drag fields on to form, complete wizard steps...no problem!

Close VB.Net, go back to Access, add field called "Section" (text
field), add some dummy data (i.e., A, B, C, etc)

Create a new VB.Net project, follow steps above, come up with the
following error:

The wizard detected the following problems when configuring the data
adapter
"OleDbDataAdapter1".

Details:
Generated SELECT statement.

IErrorInfo.GetDescription failed with E_FAIL(0x80004005).

For some reason, it seems that ADO.Net (or at least the wizard)
doesn't like a field named Section.

Any ideas on this?

Thanks,
Dave
 
Sounds like section is a reserved word in access, and the .net wizard can't
deal with it properly.

Yet another reason to avoid using the wizard and code by hand.
 
On Thu, 15 Jan 2004 16:24:40 GMT, (e-mail address removed) (Dave) wrote:

¤ I've run across a strange error when creating a simple ADO.Net
¤ connection in VB.Net 2003
¤
¤ To replicate an error:
¤ Create an Access database (2002) with table named "Student" and fields
¤ SID (Autofill), FirstName and LastName.
¤
¤ Put some dummy data in table.
¤
¤ Start a new VB.Net application, create a new connection to your
¤ database, drag fields on to form, complete wizard steps...no problem!
¤
¤ Close VB.Net, go back to Access, add field called "Section" (text
¤ field), add some dummy data (i.e., A, B, C, etc)
¤
¤ Create a new VB.Net project, follow steps above, come up with the
¤ following error:
¤
¤ The wizard detected the following problems when configuring the data
¤ adapter
¤ "OleDbDataAdapter1".
¤
¤ Details:
¤ Generated SELECT statement.
¤
¤ IErrorInfo.GetDescription failed with E_FAIL(0x80004005).
¤
¤ For some reason, it seems that ADO.Net (or at least the wizard)
¤ doesn't like a field named Section.
¤
¤ Any ideas on this?

Yes, either enclose within brackets e.g. [Section] or don't use Access or ODBC reserved words:

ACC2002: Reserved Words in Microsoft Access
http://support.microsoft.com/default.aspx?scid=kb;en-us;286335

ACC2002: Microsoft Jet 4.0 Reserved Words
http://support.microsoft.com/default.aspx?scid=kb;en-us;321266

http://msdn.microsoft.com/library/default.asp?url=/library/en-us/odbc/htm/odappcpr_17.asp


Paul ~~~ (e-mail address removed)
Microsoft MVP (Visual Basic)
 
Back
Top