title: vb.net call the same function twice from button Event Click
body: <p>This is my code on button event click function</p>
  
  <pre><code>Dim con As New Koneksi
  DataGridView1.Rows.Add(con.getIdTambahBarang(cbBarang.Text), _
                         con.getNamaTambahBarang(cbBarang.Text), _
                         con.getHargaTambahBarang(cbBarang.Text), _
                         txtJumlah.Text)
  </code></pre>
  
  <p>This is my class Koneksi code :</p>
  
  <pre><code>Public Function getIdNamaHargaTambahBarang(ByVal namaBarang As String, ByVal params As String) As String
      Dim id As String = ""
      Dim nama As String = ""
      Dim harga As String = ""
      Try
          bukaKoneksi()
          cmd.Connection = con
          cmd.CommandType = CommandType.Text
          cmd.CommandText = "SELECT * FROM barang WHERE nama_barang like '" &amp; namaBarang &amp; "'"
          reader = cmd.ExecuteReader
          If (reader.Read()) Then
              If params = "getNama" Then
                  nama = reader.GetString(1)
                  Return nama
              End If
              If params = "getHarga" Then
                  harga = reader.GetDouble(2).ToString
                  Return harga
              End If
              If params = "getId" Then
                  id = reader.GetString(0)
                  Return id
              End If
          End If
          tutupKoneksi()
      Catch ex As Exception
      End Try
  End Function
  
  Public Function getIdTambahBarang(ByVal namaBarang As String) As String
      Return getIdNamaHargaTambahBarang(namaBarang, "getId")
  End Function
  
  Public Function getNamaTambahBarang(ByVal namaBarang As String) As String
      Return getIdNamaHargaTambahBarang(namaBarang, "getNama")
  End Function
  
  Public Function getHargaTambahBarang(ByVal namaBarang As String) As String
      Return getIdNamaHargaTambahBarang(namaBarang, "getHarga")
  End Function
  </code></pre>
  
  <p>Both of the code above, produces</p>
  
  <blockquote>
    <p>'System.InvalidOperationException' occurred in System.Data.dll error.</p>
  </blockquote>
  
  <p>When I debug it, the second call of con produces this error. It seems that in VB.NET, the instance class function only can called once at a time, any solution?</p>