Talk2Tom11 Posted January 15, 2007 Posted January 15, 2007 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. Quote
Administrators PlausiblyDamp Posted January 16, 2007 Administrators Posted January 16, 2007 You need to set the command's connection to be your active connection. Something like ID3.Connection = Con3 should do the trick. Quote Posting Guidelines FAQ Post Formatting Intellectuals solve problems; geniuses prevent them. -- Albert Einstein
Recommended Posts
Join the conversation
You can post now and register later. If you have an account, sign in now to post with your account.