The brackets may only help if the database engine is having the problem.
"When" is also a reserved word in .Net languages, and as such may cause
problems for our code generators (such as those that are invoked by
dragging and dropping things from the Server Explorer), in particular,
strongly typed datasets. In this case, however, I have been able to
reproduce the E_fail by writing my own ADO.Net code, as follows:
Dim oCn As New
OleDbConnection("provider=microsoft.jet.oledb.4.0;data
source=c:\northwind.mdb;")
Dim oDa As New OleDbDataAdapter("SELECT MyID, When FROM Tester",
oCn)
Dim oDs As New DataSet
Try
oDa.Fill(oDs, "Tester")
Catch ex As Exception
MessageBox.Show(ex.Message)
End Try
I strongly advise avoiding keywords in database column or table names. A
more appropriate column name might be "EventDate" or "EventTime" or
something similar, which also has the benefit of being somewhat more
descriptive. I don't believe there's another workaround. I've tried
aliasing the field name using "When as X" instead of When, and this does
not solve the problem. Note that SELECT * does appear to work. However, you
may have other problems working with the DataTable.
Steven Bras, MCSD
Microsoft Developer Support/Data Access Technologies
This posting is provided "AS IS" with no warranties, and confers no rights.
Microsoft Security Announcement: Have you installed the patch for Microsoft
Security Bulletin MS03-026? If not Microsoft strongly advises you to
review the information at the following link regarding Microsoft Security
Bulletin MS03-026
http://www.microsoft.com/security/security_bulletins/ms03-026.asp and/or to
visit Windows Update at
http://windowsupdate.microsoft.com to install the
patch. Running the SCAN program from the Windows Update site will help to
insure you are current with all security patches, not just MS03-026.