Results 1 to 2 of 2

Thread: [RESOLVED] Operation is not allowed when the object is open

  1. #1

    Thread Starter
    Member
    Join Date
    Jan 2013
    Posts
    48

    Resolved [RESOLVED] Operation is not allowed when the object is open

    i try to insert a new data in table but this error occur i'am using vb6 and my sql database

    Code:
    On Error GoTo cr
    If studentave.text = 0 Or (studentave.text < 70 Or studentave.text > 100) Then
        MsgBox "invalid 'STUDENT AVERAGE' value.this field is required,plese enter a value", vbExclamation, ""
        
    ElseIf studentfirstname.text = "" Then
        MsgBox "invalid 'FIRST NAME' value.this field is required,plese enter a value", vbExclamation, ""
    ElseIf studentmiddlename.text = "" Then
        MsgBox "invalid 'MIDDLE NAME' value.this field is required,plese enter a value", vbExclamation, ""
    ElseIf studentlastname.text = "" Then
        MsgBox "invalid 'LAST NAME' value.this field is required,plese enter a value", vbExclamation, ""
    ElseIf studentplaceofbirth.text = "" Then
        MsgBox "invalid 'PLACE OF BIRTH' value.this field is required,plese enter a value", vbExclamation, ""
    ElseIf studenthomeaddress.text = "" Then
        MsgBox "invalid 'HOME ADDRESS' value.this field is required,plese enter a value", vbExclamation, ""
    
    ElseIf gender.text = "" Then
        MsgBox "invalid 'GENDER' value.this field is required,plese enter a value", vbExclamation, ""
    ElseIf txtfathername.text = "" Then
        MsgBox "invalid 'FATHER NAME' value.this field is required,plese enter a value", vbExclamation, ""
    ElseIf mothername.text = "" Then
        MsgBox "invalid 'MOTHER NAME' value.this field is required,plese enter a value", vbExclamation, ""
    ElseIf guardianname.text = "" Then
        MsgBox "invalid 'GUARDIAN NAME' value.this field is required,plese enter a value", vbExclamation, ""
    ElseIf lastschoolname.text = "" Then
        MsgBox "invalid 'SCHOOL LAST ATTENDED NAME ' value.this field is required,plese enter a value", vbExclamation, ""
    ElseIf lastschooladdress.text = "" Then
        MsgBox "invalid 'SCHOOL LAST ATTENDED ADDRESS' value.this field is required,plese enter a value", vbExclamation, ""
    ElseIf txtcitizenship.text = "" Then
        MsgBox "invalid 'citizenship' value.this field is required,plese enter a value", vbExclamation, ""
    ElseIf txtreligon.text = "" Then
        MsgBox "invalid 'religion' value.this field is required,plese enter a value", vbExclamation, ""
    ElseIf txtmocc.text = "" Then
        MsgBox "invalid 'mother occupation' value.this field is required,plese enter a value", vbExclamation, ""
    ElseIf txtfocc.text = "" Then
        MsgBox "invalid 'father occupation' value.this field is required,plese enter a value", vbExclamation, ""
    ElseIf txtgocc.text = "" Then
        MsgBox "invalid 'guardian occupation' value.this field is required,plese enter a value", vbExclamation, ""
    Else
        
        'sql = "insert into studentrecord (firstname,middlename,lastname,placeofbirth,homeaddress,general_average,gender,bithday,father_name,mother_name,guardian_name,mother_phonenumber,father_phonenumber,guardianphonenumber,student_number,schoollastattended,schoollastattendedaddress)  values ('" & studentfirstname.text & "','" & studentmiddlename.text & "','" & studentlastname.text & "','" & studentplaceofbirth.text & "','" & studenthomeaddress.text & "','" & studentave.text & "','" & gender.text & "','" & dtbirthdate.Value & "','" & txtfathername.text & "', '" & mothername.text & "','" & guardianname.text & "','" & mothercontact.text & "','" & fathercontact.text & "','" & guardiancontact.text & "','" & studentnumber.Caption & "','" & lastschoolname.text & "','" & lastschooladdress.text & "')"
        sql = "select * from studentrecord"
        getandsave (sql)
        rs.AddNew
        rs.Fields("firstname") = Trim(studentfirstname.text)
        rs.Fields("middlename") = Trim(studentmiddlename.text)
        rs.Fields("lastname") = Trim(studentlastname.text)
        rs.Fields("placeofbirth") = studentplaceofbirth.text
        rs.Fields("homeaddress") = studenthomeaddress.text
        rs.Fields("general_average") = studentave.text
        rs.Fields("gender") = gender.text
        rs.Fields("bithday") = dtbirthdate.Value
        rs.Fields("father_name") = txtfathername.text
        rs.Fields("mother_name") = mothername.text
        rs.Fields("guardian_name") = guardianname.text
        rs.Fields("mother_phonenumber") = mothercontact.text
        rs.Fields("father_phonenumber") = fathercontact.text
        rs.Fields("guardianphonenumber") = guardiancontact.text
        rs.Fields("student_number") = studentnumber.Caption
        rs.Fields("schoollastattended") = lastschoolname.text
        rs.Fields("schoollastattendedaddress") = lastschooladdress.text
        rs.Fields("sy") = GetSetting("parkridge", "enrollment", "activeschoolyear", "")
        rs.Fields("religon") = txtreligon.text
        rs.Fields("citizenship") = txtcitizenship.text
        rs.Fields("mother_occ") = txtmocc.text
        rs.Fields("father_occ") = txtfocc.text
        rs.Fields("bloodtype") = cboblood.text
        rs.Fields("guardian_occ") = txtgocc.text
        rs.Fields("fullname") = studentfirstname.text & ", " & studentmiddlename.text & " " & studentlastname.text
        'Path
        imgfile.Open
        imgfile.Type = adTypeBinary
        imgfile.LoadFromFile CommonDialog1.FileName
        rs.Fields("photo") = imgfile.Read
        rs.Update
        imgfile.Close
        
        ''SSAVE SETTING sa student count
        SaveSetting "parkridge", "enrollmentdatabase", "studentcount", student_count
    
    
    
        
        
        
        
        
        MsgBox "new student information sucessfully added", vbInformation, ""
    
        
        
        
     
        Call resetfields
        'Unload Me
        '''herr
       
    End If
    
    Exit Sub
    cr:
    If Err.number = 13 Then
    
        MsgBox "invalid 'STUDENT AVERAGE' value.this field is required,plese enter a value", vbExclamation, ""
        studentave.text = 0
    
    ElseIf Err.number = -2147217900 Then
        MsgBox "student already exists in the record!!!", vbExclamation
        'Unload Me
        
    Else
     
     MsgBox Err.Description
     MsgBox Err.number
    
    End If

  2. #2
    PowerPoster make me rain's Avatar
    Join Date
    Sep 2008
    Location
    india/Hubli
    Posts
    2,208

    Re: Operation is not allowed when the object is open

    i almost forgotten vb6.
    but as for as the error notification is concern, it may be that
    your database table is kept open in design view / or locked for insert edit delete
    just check it.

    by the way what provider / connector you are using to connect to MySQL data base !
    The averted nuclear war
    My notes:

    PrOtect your PC. MSDN Functions .OOP LINUX forum
    .LINQ LINQ videous
    If some one helps you please rate them with out fail , forum doesn't expects any thing other than this

Tags for this Thread

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •  



Click Here to Expand Forum to Full Width