Hey , am currently doing my school project of coming up with school reports of learners but when I tried to connect my database with the ms vb it gave me an insert into error whil I was trying to register learners .Please help.

Can't offer much help unless we can see what you have done so far. Post your code.

Imports System.Data.OleDb

Public Class Registetration_of_learners
    Dim provider As String
    Dim dataFile As String
    Dim connString As String
    Public myConnection As OleDbConnection = New OleDbConnection
    Public dr As OleDbDataReader

    Dim learnername As String
    Dim learnersurname As String
    Dim dateofbirth As Date
    Dim gender As String
    Dim studentno As Integer
    Dim grade As String

    Private Sub Registration_of_learners_Load(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles MyBase.Load
        provider = "Provider=Microsoft.ACE.OLEDB.12.0;Data Source ="
        dataFile = "C:\Users\nnashipili\Documents\Visual Studio 2010\Projects\Reports Management System\WindowsApplication3\Podheni_Matete.accdb"
        connString = provider & dataFile
        myConnection.ConnectionString = connString
    End Sub

    Private Sub RRegisterButton_Click(sender As Object, e As System.EventArgs) Handles RRegisterButton.Click

        Dim str As String
        str = "INSERT INTO Learners ([Registration_number], [Learner's_name], [Learner's_surname], [Date_Of_Birth], [Grade],[Gender],) values ([studentno], [learnername], [learnersurname], [dateofbirth], [grade],[Gender])"

        Dim cmd As OleDbCommand = New OleDbCommand(str, myConnection)

        cmd.Parameters.Add(New OleDbParameter("studentno", CType(RStudentNo_TextBox.Text, Integer)))
        cmd.Parameters.Add(New OleDbParameter("learnername", CType(RNameTextBox.Text, String)))
        cmd.Parameters.Add(New OleDbParameter("learnersurname", CType(RSurnameTextBox.Text, String)))
        cmd.Parameters.Add(New OleDbParameter("dateofbirth", CType(RDOBTextBox.Text, Date)))
        cmd.Parameters.Add(New OleDbParameter("grade", CType(RGradeTextBox.Text, String)))
        cmd.Parameters.Add(New OleDbParameter("Gender", CType(RGenderComboBox.SelectedItem, String)))

            MessageBox.Show("Successfully Registered!")
            RGenderComboBox.Text = String.Empty
        Catch ex As Exception
        End Try
    End Sub

    Private Sub RGenderComboBox_Click(sender As Object, e As System.EventArgs) Handles RGenderComboBox.Click
    End Sub
    Private Sub RBackButton_Click(sender As Object, e As System.EventArgs) Handles RBackButton.Click
    End Sub

End Class

Typically, when you do an INSERT you include some values to go with the field names. For example

INSERT INTO mytable (LastName,FirstName,Age) VALUES('Smith','George',27)

Your query didn't do this.

I'll also add that you should be using Parameterized Queries.

Be a part of the DaniWeb community

We're a friendly, industry-focused community of 1.18 million developers, IT pros, digital marketers, and technology enthusiasts learning and sharing knowledge.