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