I load a Datatable to a datagrid view by calling the following function:
Public Sub GetData(ByVal selectCommand As String, ByVal bindingSource As BindingSource, ByVal table As DataTable)
Try
Dim connectionString As String = "Provider=Microsoft.Jet.OLEDB.4.0;Data Source=C:\Users\adm\Desktop\222.mdb"
Me.dataAdapter = New OleDbDataAdapter(selectCommand, connectionString)
Dim commandBuilder As New OleDbCommandBuilder(Me.dataAdapter)
table.Locale = System.Globalization.CultureInfo.InvariantCulture
Me.dataAdapter.Fill(table)
bindingSource.DataSource = table
Catch ex As OleDbException
MessageBox.Show(ex.Message)
End Try
End Sub
And here is the function call:
GetData("select * from products where ID=1 or ID=2", bindingSource1, t1)
Now, does the data table define the column types as they are from the source database?
Because when I try to add data to a DateTime column, it says that the column is of type integer but in Access I can see that it is a DateTime Column. So do I need to specify each type for each column or it is done automatically?
Check the type of the column in which you are passing the date value make sure that the value is not
int.If it so then change it todatetimeEDIT
Go to the properties of your datatable and change the column type to
datetime