Imports System.Data
Imports System.Data.OleDb
Public Class Form1
Dim objConn As New OleDbConnection
Dim objCmd As New OleDbCommand
Dim strConnString, strSQL As String
Private Sub pnlAdd_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles pnlAdd.Click
strConnString = "Provider=Microsoft.Jet.OLEDB.4.0;Data Source=database.mdb;Jet OLEDB:Database Password=;"
strSQL = "INSERT INTO member (CustomerID,Username,Password,Name) " & _
" VALUES " & _
" ('" & Me.TextBox4.Text & "','" & Me.TextBox1.Text & "','" & Me.TextBox2.Text & "','" & Me.TextBox3.Text & "')"
objConn.ConnectionString = strConnString
objConn.Open()
With objCmd
.Connection = objConn
.CommandText = strSQL
.CommandType = CommandType.Text
End With
Me.pnlAdd.Visible = False
Try
objCmd.ExecuteNonQuery()
Me.lblStatus.Text = "Record Inserted"
Me.lblStatus.Visible = True
Catch ex As Exception
Me.lblStatus.Visible = True
Me.lblStatus.Text = "Record can not insert Error (" & ex.Message & ")"
End Try
objConn.Close()
objConn = Nothing
End Sub
End Class