i cant add in the data?
code of add info:
Private Sub btnAdd_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles btnAdd.Click
If String.IsNullOrWhiteSpace(txtadmin.Text) Or String.IsNullOrWhiteSpace(txtname.Text) Or String.IsNullOrWhiteSpace(txtcourse.Text) Or String.IsNullOrWhiteSpace(txtic.Text) Or String.IsNullOrWhiteSpace(txtgender.Text) Or String.IsNullOrWhiteSpace(txtaddress.Text) Or String.IsNullOrWhiteSpace(txttel.Text) Or String.IsNullOrWhiteSpace(txtemail.Text) Or String.IsNullOrWhiteSpace(txttpye.Text) Then
MessageBox.Show("Please complete the on the box.", "Authentication Error", MessageBoxButtons.OK, MessageBoxIcon.Error)
Exit Sub
End If
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
If Conn.State = ConnectionState.Open Then Conn.Close()
Conn.Open()
Dim sql As String = "insert into tbl_datain ([UserName] values('" & txtname.Text & "' AdminNo = '" & txtadmin.Text & "'Course Title = '" & txtcourse.Text & "'""'ICNo = '" & txtic.Text & "'""'Gender = '" & txtgender.Text & "'""'Address= '" & txtaddress.Text & "'""'TelNo = '" & txttel.Text & "'""'Email = '" & txtemail.Text & "' Type ='" & txttpye.Text & "')"
Dim sqlCom As New System.Data.OleDb.OleDbCommand(sql, Conn)
sqlCom.Connection = Conn
Dim result As Integer = sqlCom.ExecuteNonQuery()
sqlCom.Dispose()
Conn.Close()
If result > 0 Then
MessageBox.Show("Successfully created.")
Else
MessageBox.Show("Failure to create.")
End If
txtname.Text = ""
txtadmin.Text = ""
txtcourse.Text = ""
txtic.Text = ""
txtgender.Text = ""
txtaddress.Text = ""
txttel.Text = ""
txtemail.Text = ""
txtname.Focus()
Catch ex As Exception
MessageBox.Show("Failed to connect to Database..", "Database Connection Error", MessageBoxButtons.OK, MessageBoxIcon.Error)
End Try
End Sub