here is may code the error is .ExecuteNonQuery()
thx for helping

Imports System.Data.OleDb
Public Class registration


    Private Sub registration_Load(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles MyBase.Load
        Dim connectionstring As String = "Provider=Microsoft.ACE.OLEDB.12.0;Data Source=|datadirectory|\db1.accdb; persist security info = false"


        conn.ConnectionString = connectionstring

        If conn.State = ConnectionState.Closed Then
            MsgBox("open")
        Else
            MsgBox("close")
        End If

    End Sub

    Private Sub Button1_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Button1.Click
        Try
            Dim SqlQuery As String = "INSERT INTO tblstu (fname,lname,grade)VALUES('" & TextBox1.Text & "' , '" & TextBox2.Text & "' ,'" & TextBox3.Text & "');"
            Dim SqlCommand As New OleDbCommand

            With SqlCommand
                .CommandText = SqlQuery
                .Connection = conn
                .ExecuteNonQuery()
            End With
            MsgBox("One record Successfully Added..")
        Catch ex As Exception
            MsgBox(ex.ToString)
        End Try
    End Sub
End Class

ExecuteNonQuery()

is not an error. It is a statement. Please post the text of the error message. Because the source of the error is likely the query, please also post the value of SqlQuery. It would also help to know the field types of your database table. For example, if grade is a string then the query may be OK. If grade is a number then you shouldn't have single quotes around the value for grade.

Be a part of the DaniWeb community

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