this is my code i dose not work: ( help me i am create for new user from VB with access)
Public Class newuserForm
Private Sub btncreate_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles btncreate.Click
If txtword.Text = "" Or txtid.Text = "" Then
MessageBox.Show("Please complete the required fields..", "Authentication Error", MessageBoxButtons.OK, MessageBoxIcon.Error)
Else
Dim Conn As System.Data.OleDb.OleDbConnection
Dim ConnectionString As String = "Provider=Microsoft.ACE.OLEDB.12.0;Data Source=C:\temp\Database1.accdb"
Conn = New System.Data.OleDb.OleDbConnection(ConnectionString)
Try
Dim sql As String = "insert into tbl_datain ([UserID], [PassWord]) values( " & txtid.Text & " , " & txtword.Text & " ')"
Dim sqlCom As New System.Data.OleDb.OleDbCommand(sql, Conn)
sqlCom.Connection = Conn
Conn.Open()
Dim sqlRead As System.Data.OleDb.OleDbDataReader = sqlCom.ExecuteReader(sql)
If sqlRead.Read() Then
MessageBox.Show("Success created")
Else
MessageBox.Show("You already in", "Authentication Failure", MessageBoxButtons.OK, MessageBoxIcon.Exclamation)
txtid.Text = ""
txtword.Text = ""
txtid.Focus()
End If
Catch ex As Exception
MessageBox.Show("Failed to connect to Database..", "Database Connection Error", MessageBoxButtons.OK, MessageBoxIcon.Error)
End Try
End If
end sub
end class