Solved

Error, invalid operation, connection closed

Posted on 2007-11-23
2
2,947 Views
Last Modified: 2012-06-27
Why do i get this error now?

I dont see anything wrong

error explanation in code below
Me.ListViewstatus.Clear()
        Dim forbindelse1 As New System.Data.OracleClient.OracleConnection
 
        forbindelse1.ConnectionString = "*****"
        forbindelse1.Open()
 
        Dim kommando As New System.Data.OracleClient.OracleCommand("select vare_navn, lagerstatus, lev_navn FROM vare ORDER BY lagerstatus")
        Dim dataleser As OracleClient.OracleDataReader
        dataleser = kommando.ExecuteReader()-----------------> Invalid operation connection closed
 
        With Me.ListViewstatus
            .GridLines = True
            .MultiSelect = False
            .FullRowSelect = True
            .View = View.Details
            .HideSelection = False
            .Columns.Add("Leverandør", 100, HorizontalAlignment.Center)
            .Columns.Add("Varenavn", 100, HorizontalAlignment.Center)
            .Columns.Add("Lagerstatus", 55, HorizontalAlignment.Center)
 
 
 
        End With
 
        Dim lstItem As ListViewItem
        While dataleser.Read()
            lstItem = New ListViewItem()
            lstItem.Text = dataleser.GetString(2)
            lstItem.SubItems.Add(dataleser.GetString(0))
            lstItem.SubItems.Add(dataleser.GetInt32(1))
 
 
            Me.ListViewstatus.Items.Add(lstItem)
 
 
        End While
 
        dataleser.Close()
        forbindelse1.Close()

Open in new window

0
Comment
Question by:leeds2000
[X]
Welcome to Experts Exchange

Add your voice to the tech community where 5M+ people just like you are talking about what matters.

  • Help others & share knowledge
  • Earn cash & points
  • Learn & ask questions
2 Comments
 
LVL 55

Accepted Solution

by:
Jaime Olivares earned 500 total points
ID: 20338562
I think you need:
        Dim kommando As New System.Data.OracleClient.OracleCommand("select vare_navn, lagerstatus, lev_navn FROM vare ORDER BY lagerstatus", forbindelse1)
0
 
LVL 47

Expert Comment

by:Wayne Taylor (webtubbs)
ID: 20338566
The command also needs a connection.....
        forbindelse1.ConnectionString = "*****"
        forbindelse1.Open()
 
        Dim kommando As New System.Data.OracleClient.OracleCommand("select vare_navn, lagerstatus, lev_navn FROM vare ORDER BY lagerstatus", forbindelse1)
        Dim dataleser As OracleClient.OracleDataReader
        dataleser = kommando.ExecuteReader()

Open in new window

0

Featured Post

On Demand Webinar - Networking for the Cloud Era

This webinar discusses:
-Common barriers companies experience when moving to the cloud
-How SD-WAN changes the way we look at networks
-Best practices customers should employ moving forward with cloud migration
-What happens behind the scenes of SteelConnect’s one-click button

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

Well, all of us have seen the multiple EXCEL.EXE's in task manager that won't die even if you call the .close, .dispose methods. Try this method to kill any excels in memory. You can copy the kill function to create a check function and replace the …
I think the Typed DataTable and Typed DataSet are very good options when working with data, but I don't like auto-generated code. First, I create an Abstract Class for my DataTables Common Code.  This class Inherits from DataTable. Also, it can …
In an interesting question (https://www.experts-exchange.com/questions/29008360/) here at Experts Exchange, a member asked how to split a single image into multiple images. The primary usage for this is to place many photographs on a flatbed scanner…
Are you ready to implement Active Directory best practices without reading 300+ pages? You're in luck. In this webinar hosted by Skyport Systems, you gain insight into Microsoft's latest comprehensive guide, with tips on the best and easiest way…

739 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question