#1
  1. No Profile Picture
    Contributing User
    Devshed Newbie (0 - 499 posts)

    Join Date
    Sep 2003
    Location
    Montreal, Canada
    Posts
    486
    Rep Power
    12

    URGENT - Help me guys please ! I am in tr@#bl&*%#@!


    So here is the bug that it's telling me

    Code:
    Une exception non gérée du type 'System.InvalidOperationException' s'est produite dans system.data.dll
    
    Informations supplémentaires_: ExecuteNonQuery requiert une connexion ouverte et disponible. L'état actuel de la connexion est Open, Fetching.
    If I translate it :
    Code:
    A exception have excaped, tye pof 'System.InvalidOperationException' occured in the system.data.dll
    
    Other information : ExecuteNonQuery require an open and disponible connexion. It's state now is Open and Fetching
    Here is a part of my code in the function where I am using that.
    Code:
    If frmItems.OleDbConnection1.State <> ConnectionState.Open Then
                frmItems.OleDbConnection1.Open()
            End If
    
            'Connexion pour la requete
            OleDBCommand.Connection = frmItems.OleDbConnection1
    
            'Construit la requete
            OleDBCommand.CommandText = "select * from adresse where noReleve = (select noReleve from releve where codeProjet = '" + NoReleve + "' )"
    
            OleDataR = OleDBCommand.ExecuteReader
    
            'Lit ligne par ligne les résultats trouvé, met dans un tableau
            'et les met dans le listbox pour les afficher.
            If OleDataR.Read() Then
    
                Do 'Chaque ligne retourné lecture
                    'remet la valeur a false pour paser au prochain enreg.
                    bValide = False
    
                    For iCompteur = 0 To (tabRueNumero.Length - 1)
    
                        If OleDataR.Item("noRue") = tabRueNumero(iCompteur) Then
                            'ville a été trouvé donc ne supprime pas
                            bValide = True
                            'Pas besoin de rajouter cette ville dans les adresse
                            tabRueValide(iCompteur) = True
    
                            Exit For 'sort de la loop
                        End If
                    Next
    
                    If bValide = False Then
                        'Connexion pour la comm effacer et création de la requête
                        OleDBComEffacer.Connection = frmItems.OleDbConnection1
                        OleDBComEffacer.CommandText = "Delete adresse where (norue = '" & _
                                                    OleDataR.Item("norue") & "') and (noreleve = " & _
                                                    "(select noreleve from releve where codeprojet = '" & _
                                                    NoReleve + "'))"
                        OleDBCommand.ExecuteNonQuery()
    
                    End If
    
                Loop Until Not OleDataR.Read
    I bold and underlne where the bug occured.


    I hope someone can help me cause I don't know what to do anymore !
    Last edited by Watever; September 30th, 2003 at 10:52 AM.
  2. #2
  3. No Profile Picture
    Junior Member
    Devshed Newbie (0 - 499 posts)

    Join Date
    Sep 2003
    Location
    SC
    Posts
    26
    Rep Power
    0

    Unhappy Trying hard to translate issue!


    It sounds like you are trying it implement some sort of COM object into your code. If so, it looks like the connection strings you are using are not any good. Something like, it's open but cannot close (dispose). You are trying to manage the connectivity, but in .NET you do not have too.

    I may be way off on this, but I do not speak or read spanish. And I'm trying to associate it with some common issues. If you need code on the implementation of a COM object, please let me know more about your platform and what the object was written in.

    Good luck!
  4. #3
  5. No Profile Picture
    Junior Member
    Devshed Newbie (0 - 499 posts)

    Join Date
    Sep 2003
    Location
    SC
    Posts
    26
    Rep Power
    0

    Talking


    or French for that matter.... (what language is it?)
  6. #4
  7. No Profile Picture
    Contributing User
    Devshed Newbie (0 - 499 posts)

    Join Date
    Sep 2003
    Location
    Montreal, Canada
    Posts
    486
    Rep Power
    12
    yeah it's damn CALIS D'OSTIE de French

    lol, I work for a french canadian company and I am a french canadian too, that's why my written language in english is just soo bad !



    What I am trying to do is to delete some information in the database that I don't need anymore, and that have been changed.

    For that, I have a query that find me all the rows that refer to a document, then I compare them with the ones that are in a combobox. If the item is not in the combobox then I delete them.
    and then it's continu to read the result from the query to compare them with the combobox items and again delete the ones that are not necessary.

    I hope you understand what I am talking about ?
    and what is a COM ? I don't know if that's what I am trying to do or not, I just don't know what's that.
    but I beliee what I am doing is pretty simple. I tought

    May be there is another way to delete the items I want to ? I tryed using a dataset and datarow but that was way too long cause I couldn't make a query in it and that's really slow when you have a lot of items in it cause you need to read all of them to find the ones you don't need. And when I tryed to delete more then 1 items it's bugged. soo that's why I reformulated in this one.

    So if that one works, it's should be way faster imo.

    I hope you can help me and that I gave you the information to you so you can help me.
  8. #5
  9. No Profile Picture
    Contributing User
    Devshed Newbie (0 - 499 posts)

    Join Date
    Oct 2002
    Location
    Flint, MI
    Posts
    328
    Rep Power
    13
    Your problem is at the very end, with the Execute method. Instead of calling it on OleDBComEffacer you called it on OleDBCommand.

    I'm not sure, but you might want to set strict=on in your file. It might have caught this error.
    Clay Dowling
    Lazarus Notes
    Articles and commentary on web development
    http://www.lazarusid.com/notes/
  10. #6
  11. No Profile Picture
    Contributing User
    Devshed Newbie (0 - 499 posts)

    Join Date
    Sep 2003
    Location
    Montreal, Canada
    Posts
    486
    Rep Power
    12
    ClayDowling : yeah you are right on that.

    But my main problem then is that it's telling me that I already have a datarow associated with that connection.

    Is it possible that you can't have 2 dataread working at the same time ?

    Cause I only have 1 but when you use the OleDbComEffacer.ExecuteNonQuery, that will "in theory" return you a dataread information. Might it be my problem ?

    Then I would need to close the other one. But how does I continu to read in the table then ? I need to do all the function again in a loop ? I would be loosing time and what I want to do at first.

    2 session ?
  12. #7
  13. No Profile Picture
    Contributing User
    Devshed Newbie (0 - 499 posts)

    Join Date
    Oct 2002
    Location
    Flint, MI
    Posts
    328
    Rep Power
    13
    You're probably working off a server-side dataset. With most database engines, using a server-side dataset does tie up the connection pretty well.

    You have two options: create another connection for removing records, or use a client-side dataset and take the performance hit. This doesn't look like the sort of code that gets run every hour on the hour, so the performance hit shouldn't be too bad. How big is the dataset that you're pulling down, anyway?
    Clay Dowling
    Lazarus Notes
    Articles and commentary on web development
    http://www.lazarusid.com/notes/
  14. #8
  15. No Profile Picture
    Contributing User
    Devshed Newbie (0 - 499 posts)

    Join Date
    Sep 2003
    Location
    Montreal, Canada
    Posts
    486
    Rep Power
    12
    yeah it's not something that is always running etc...

    soo I just decided to take a real easy way. I just created a dynamic table where I will add the information I need. And when the oledataread is ended, just read them and delete my information. So that way I won't have 2 running at the same time.

    It's gonna take a little bit more time and it's not a good way to do it. But I want to finnish fast to go on something else. And the program isn't really big and it's for us so doesn't matter .

    the only thing that might happen is that the girl who is using it will come and see me about something, and she is cute so it's ok.


    now just need to find how the dynamic tables work in vb.net and I will be set.

IMN logo majestic logo threadwatch logo seochat tools logo