Solved

Error, invalid operation, connection closed

Posted on 2007-11-23
2
2,942 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
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

Courses: Start Training Online With Pros, Today

Brush up on the basics or master the advanced techniques required to earn essential industry certifications, with Courses. Enroll in a course and start learning today. Training topics range from Android App Dev to the Xen Virtualization Platform.

Question has a verified solution.

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

A while ago, I was working on a Windows Forms application and I needed a special label control with reflection (glass) effect to show some titles in a stylish way. I've always enjoyed working with graphics, but it's never too clever to re-invent …
Calculating holidays and working days is a function that is often needed yet it is not one found within the Framework. This article presents one approach to building a working-day calculator for use in .NET.
This Micro Tutorial hows how you can integrate  Mac OSX to a Windows Active Directory Domain. Apple has made it easy to allow users to bind their macs to a windows domain with relative ease. The following video show how to bind OSX Mavericks to …
This video shows how to use Hyena, from SystemTools Software, to bulk import 100 user accounts from an external text file. View in 1080p for best video quality.

813 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

Need Help in Real-Time?

Connect with top rated Experts

12 Experts available now in Live!

Get 1:1 Help Now