How to bind datetimepicker to MS access 2013 database?

Asked By 20 points N/A Posted on -

How do I bind datetimepicker to Microsoft access 2013 database? the splash form, admin login form, main dashboard form has been created, Also, the Add new student form , DateTimePicker, combo box on the form and all the text boxes was successfully made. The problem now lies in How to bind the DateTimePicker and Combo box to the Access database. Also, How do I create the report form with all its features intact?


Answered By 0 points N/A #192755

How to bind datetimepicker to MS access 2013 database?


To Bind the DateTimePicker to an MS Access Database , use this code

On save button click, Use below code

Dim connection As SqlConnection = New sqlconnection()

connection.ConnectionString = "YOUR CONNECTION STRING"


Dim adp As SqlDataAdapter = New SqlDataAdapter("select * from Table where Date between DateTimePicker1.Value and DateTimePicker2.Value", connection)

Dim ds As DataSet = New DataSet()


DataGridView1.DataSource = ds.Tables(0)

To Bind ComboBox to an MS Access database , use this code

 Private Sub FillCombo()
            Dim fillcon As New OleDbConnection(@"Provider=Microsoft.Jet.OLEDB.4.0;Data Source=path to access file.mdb;")
            Dim asql As String = ("SELECT * FROM Items ORDER BY ItemName")
            Dim da As New OleDbDataAdapter(asql, fillcon)
            Dim ds As New DataSet
            ItemNameCombo.ValueMember = "ItemName"
            ItemNameCombo.DataSource = ds.Tables(0)
            ItemNameCombo.SelectedIndex = 0
        Catch ex As Exception
            MsgBox("ERROR : " & ex.Message.ToString)
        End Try
    End Sub

Login/Register to Answer

Related Questions