Click here to Skip to main content
15,913,465 members
Please Sign up or sign in to vote.
0.00/5 (No votes)
See more:
I want to get data from DateTimePicker1 and DateTimePicker2 as MM/dd/yyyy and display all records between those dates in ms access database table named 'user' and located in E:\cessuer.accdb I want to display this in UserDataGridView

What I have tried:

Private Sub Button2_Click(sender As Object, e As EventArgs) Handles Button2.Click
        provider = "Provider=Microsoft.ACE.OLEDB.12.0;Data Source="
        dataFile = "E:\cessuser.accdb"
        connString = provider & dataFile
        Dim con = New OleDbConnection
        con.ConnectionString = connString

        con.Open()




        Dim ds = New DataSet
        Dim tables = ds.Tables
        Dim da = New OleDbDataAdapter("Select * from [user] where [Submittedon] between '" & DateTimePicker1.Text & "' And '" & DateTimePicker2.Text & "'", con)

        da.Fill(ds, "user")
        Dim view = source.DataSource
        UserDataGridView.DataSource = view
    End Sub
End Class
Posted
Updated 15-Nov-17 18:53pm
v2
Comments
Graeme_Grant 16-Nov-17 0:56am    
What is the question And what is currently happening?
Azhagappan 17-Nov-17 1:10am    
S sir I am getting error.am new to vb.net and I am already displaying a data grid view and below that I have two datetimepickers from which I have to select dates and on a click of a button I need that data grid view to display all records between those two dates
Karthik_Mahalingam 17-Nov-17 1:14am    
what is the error message
kgmmurugesh 20-Nov-17 6:01am    
after getting connection, run SET DATEFORMT 'MDY'

This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)



CodeProject, 20 Bay Street, 11th Floor Toronto, Ontario, Canada M5J 2N8 +1 (416) 849-8900