title: Database connection VB6 to XAMPP
body: <p>I'm totally new to vb6 and I wanna know why this code does not work. it has runtime 424 error. what do i have to do? whenever i try running it. I can't access the db it says empty. Here's the entire code. </p>
  
  <pre><code>    Public cn As ADODB.Connection
  Public rs As ADODB.Recordset
  
  Private Sub Form_Load()
      Set cn = New ADODB.Connection
      cn.ConnectionString = "Driver={MySQL ODBC 5.1 Driver};Server=localhost;Database=db_Inventory; User=root;Password=;Option=3;"
  End Sub
  
  Private Sub Cmd_Add_Click()
   If Txt_Pname.Text = "" And Txt_Pprice.Text = "" Then
      MsgBox ("Please enter details")
   Else
      rst.Open "select * from tbl_product", db, adOpenStatic, adLockOptimistic, adCmdText
      rs.AddNew
      rs("Prod_Name") = Txt_Pname.Text
      rs("Prod_Price") = Txt_Pprice.Text
      rs.Update
      rs.Close
      MsgBox ("Product Added!")
   End If
   End Sub
  </code></pre>