title: Register VB.Net Using Access Database
body: <p>i have a problem regarding register form which i try to make it send to database ( add new record ) using data provided but its not working. Thank you very much</p>
  
  <p>Here is the UI :
  <a href="https://i.stack.imgur.com/A1rK1.png" rel="nofollow noreferrer"><img src="https://i.stack.imgur.com/A1rK1.png" alt="UI"></a></p>
  
  <p>Heres my code :</p>
  
  <pre><code>Private Sub Button1_Click(sender As Object, e As EventArgs) Handles Button1.Click
      Dim nama, uname, password, email, jk As String
      Dim idusr As Integer
  
      nama = TextBox1.Text
      uname = TextBox2.Text
      password = TextBox3.Text
      email = TextBox5.Text
      jk = ComboBox1.SelectedValue
  
      Randomize()
      ' The program will generate a number from 0 to 50
      idusr = Int(Rnd() * 50) + 1
  
      If TextBox1.Text = "" Or TextBox2.Text = "" Or TextBox3.Text = "" Or TextBox4.Text = "" Or TextBox5.Text = "" Then
          MsgBox("Please Fill All The Box First !!!")
      ElseIf TextBox3.Text &lt;&gt; TextBox4.Text Or TextBox3.TextLength &lt;= 8 Then
          MsgBox("Password do not match or missing !!!")
      Else
          Dim dbsource As String = "Provider=Microsoft.ACE.OLEDB.12.0;Data Source=C:\Michael\Tugas Materi Kuliah\VB\TA\DBUtama.accdb"
          Dim conn = New OleDbConnection(dbsource)
          Dim str = "Insert into [User]([IDUSR],[Nama],[Uname],[Pass],[Jenis Kelamin],[Email]) Values ('" &amp; idusr &amp; "','" &amp; nama &amp; "','" &amp; uname &amp; "','" &amp; password &amp; "','" &amp; jk &amp; "','" &amp; email &amp; "') ;"
          Dim cmd As OleDbCommand = New OleDbCommand(str, conn)
          Try
              cmd.ExecuteNonQuery()
              cmd.Dispose()
          Catch ex As Exception
              MsgBox("Something broke, i know its you !!")
          End Try
      End If
  End Sub
  </code></pre>
  
  <p>and Database :
  <a href="https://i.stack.imgur.com/sIrMN.png" rel="nofollow noreferrer"><img src="https://i.stack.imgur.com/sIrMN.png" alt="My database with User as table name"></a></p>