VB.Net database connection MS Access

VB.Net code to do data base connection with MS Access 2010


Private Sub btnSave_Click(sender AsSystem.Object, e AsSystem.EventArgs) HandlesbtnSave.Click

        MsgBox(“Sure! Save permanently in database”, MsgBoxStyle.Information, “SAVE”)

        Dim cnn As OleDbConnection= New OleDbConnection

        Dim cmd As OleDbCommand= New OleDbCommand

        DimconnString As String

        connString = “Provider=Microsoft.ACE.OLEDB.12.0;Data Source = E:aDBAtndcDB.accdb”

        cnn.ConnectionString = connString

        cmd.Connection = cnn

        cnn.Open()

        cmd.CommandText = “INSERT INTO Attendence ([dat], [totalPresent)”+ ” VALUES (‘” & dt.Text & “‘,'” & lblTotalPresent.Text & “‘)”

        cmd.ExecuteNonQuery()

        cnn.Close()

 End Sub