Link to home
Start Free TrialLog in
Avatar of Benvor
BenvorFlag for South Africa

asked on

Problem with sql and datetime column

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)
            connection.Open()
            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)
            da.Fill(dt)
            frmRoadCall.cbxdatetime.DataSource = dt
            frmRoadCall.cbxdatetime.DisplayMember = "Table.[DateTime]"

Open in new window

ASKER CERTIFIED SOLUTION
Avatar of Abedelhady
Abedelhady
Flag of Israel image

Link to home
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
Start Free Trial
sorry, change the combo box display member to:
frmRoadCall.cbxdatetime.DisplayMember = "Table.mydatetime"
Avatar of Benvor

ASKER

Works excellent thank you Abedelhady.