Jump to content
Xtreme .Net Talk

Recommended Posts

Posted

I am writing an inventory application that uses MS access as a backend. I am having no problems accessing and obtaining information from the database through my program except in one spot. This is the code:

 

Dim Pro As New OleDb.OleDbCommand
Dim Read2 As OleDb.OleDbDataReader
Dim Con3 As New OleDb.OleDbConnection
Dim ID3 As New OleDb.OleDbCommand

Private Sub CmbBoxProducts_SelectedIndexChanged(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles CmbBoxProducts.SelectedIndexChanged
       Con3.ConnectionString = "Provider=Microsoft.Jet.OLEDB.4.0;Data Source=C:\subdir\database.mdb;Mode=ReadWrite;Persist Security Info=False"

       If txtBoxWatch.text = "Product" Then

           ID3.Parameters.Add("Product", Data.OleDb.OleDbType.Variant)
           ID3.Parameters("Product").Value = CmbBoxProducts.Text

           Con3.Open()

           Read = ID3.ExecuteReader()

           With Read
               While .Read
                   txtBoxAmount.Items.Add(.GetValue(1))
               End While
           End With

           Con3.Close()
       End If
   End Sub

 

 

The error i am receiving is:

 

ExecuteReader: Connection property has not been initialized.

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.

Guest
Reply to this topic...

×   Pasted as rich text.   Paste as plain text instead

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

×
×
  • Create New...