Problem with sql and datetime column

Posted on 2009-05-21
Medium Priority
Last Modified: 2013-11-26
Hi experts

I have a Access db and there is a column named "DateTime" and when I try to populate a combobox with the value then I only get "System.Data.DataRowView". I know its because "DateTime" is some kind of reserved word because if I change it, it works and displays the dates from the db. Is there a way to still use this column name and get the combobox to display tha data with "DateTime"?

Thanx in advance
Dim myaccessdbpath As String = myapath
            Dim connection As OleDbConnection = CreateConnection(myaccessdbpath)
            Dim command As New OleDbCommand()
            command.CommandText = "SELECT Table.[DateTime] FROM Table"
            command.Connection = connection
            Dim dt As New DataTable()
            Dim da As New OleDbDataAdapter(command)
            frmRoadCall.cbxdatetime.DataSource = dt
            frmRoadCall.cbxdatetime.DisplayMember = "Table.[DateTime]"

Open in new window

Question by:Benvor
  • 2

Accepted Solution

Abedelhady earned 2000 total points
ID: 24438937

Try to use alias, so change your command text as:

command.CommandText = "SELECT Table.[DateTime] as mydatetime FROM Table"

and change the combo box display member to:
frmRoadCall.cbxdatetime.DisplayMember = "Table.[DateTime]"

Hopfully this may help.

Expert Comment

ID: 24438941
sorry, change the combo box display member to:
frmRoadCall.cbxdatetime.DisplayMember = "Table.mydatetime"

Author Comment

ID: 24439046
Works excellent thank you Abedelhady.

Featured Post

Free Tool: Port Scanner

Check which ports are open to the outside world. Helps make sure that your firewall rules are working as intended.

One of a set of tools we are providing to everyone as a way of saying thank you for being a part of the community.

Question has a verified solution.

Are you are experiencing a similar issue? Get a personalized answer when you ask a related question.

Have a better answer? Share it in a comment.

Join & Write a Comment

Real-time is more about the business, not the technology. In day-to-day life, to make real-time decisions like buying or investing, business needs the latest information(e.g. Gold Rate/Stock Rate). Unlike traditional days, you need not wait for a fe…
Native ability to set a user account password via AD GPO was removed because the passwords can be easily decrypted by any authenticated user in the domain. Microsoft recommends LAPS as a replacement and I have written an article that does something …
The video will let you know the exact process to import OST/PST files to the cloud based Office 365 mailboxes. Using Kernel Import PST to Office 365 tool, one can quickly import numerous OST/PST files to Office 365. Besides this, the tool also comes…
To export Lotus Notes to Outlook PST or Exchange and Domino Server files to Exchange Server or PST files with ease, go for Kernel for Lotus Notes to Outlook conversion tool. Through the video, you can watch the conversion process. A common user with…

600 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question