COMexception. operation is not allowed....

xxentric

New member
Joined
Jul 23, 2010
Messages
3
Programming Experience
Beginner
im getting an error "Operation is not allowed while object is closed"

on this line of code "Do While myRecSet.EOF = False" here is all my code

first the module/function
VB.NET:
Expand Collapse Copy
Module Module1
    Public coater As String
    Public myQuery As String
    Public myRecSet As New ADODB.Recordset
    Public Conn As ADODB.Connection
    Public Comm As ADODB.Command
    Public ChosenRecipe As String
    Public i As Integer
    Public myRecipe(0 To 50) As String



    Public Function Connect_Db(ByVal inRecSet As ADODB.Recordset, ByVal inQueryTxt As String) As Boolean

        Conn = New ADODB.Connection
        Comm = New ADODB.Command

        On Error GoTo ErrorHandler

        Conn.ConnectionString = "Provider=MSDAORA.1;Data Source=rduxu;User ID=ops$npy;Password=npy123;"

        Conn.Open()

        Comm.ActiveConnection = Conn
        Comm.CommandText = inQueryTxt

        inRecSet = Comm.Execute
        Connect_Db = True

        Exit Function

ErrorHandler:
        'MsgBox Error(Err)
        'Connect_Db = False


    End Function




End Module


AND here is the form code where i get the error

VB.NET:
Expand Collapse Copy
Public Class RecipeList
    Private Sub CANCEL_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles CANCEL.Click
        Me.Dispose()
        Coaters.Show()
    End Sub
    Private Sub RecipeList_Load(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles MyBase.Load
        If coater = "EDDY RUN" Then
            ChosenRecipe = "293K"
            i = 1
            'query program
            myQuery = "select distinct RECIPE_NAME from facet_coat_recipe where RECIPE_NAME = '" & ChosenRecipe & "'"
            'Call database function

            If Connect_Db(myRecSet, myQuery) = False Then Exit Sub
            [B][U]Do While myRecSet.EOF = False[/U][/B]
                myRecipe(i) = CStr(myRecSet.Fields(0).Value)
                CoaterLabel.Text = myRecipe(i)
                myRecSet.MoveNext()
                i = i + 1
            Loop
        End If
        If coater = "DIBS RUN" Then CoaterLabel.Text = "dibs"


    End Sub

End Class
 
Back
Top