Error creating database connection with field name "Section"

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
 
M

Marina

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.
 
P

Paul Clement

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)
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Top