7 Replies - 371 Views - Last Post: 06 January 2020 - 10:01 AM Rate Topic: ***-- 2 Votes

#1 siddhesh003   User is offline

  • New D.I.C Head

Reputation: 0
  • View blog
  • Posts: 4
  • Joined: 06-January 20

I am facing one issue related to recordset object

Posted 06 January 2020 - 01:40 AM

Issue background : I've made vb6 application "Hall and lawn managment system." Since I have made one page which can show records of booking of hall and lawn. The issue i am facing that when i am opening hall booking record the recordset object get open and when i click on lawn booking record lawn recordset object gets activated but when I reopen the "Booking record page" after closing it every time Error Occur "Operation not allowed when object is open." and when i click on debug button database connection string highlighted.
I am attaching Screenshot and pasting Code please help me and also suggest me validation if needed.

Dim con As New ADODB.Connection
Dim rec As New ADODB.Recordset
Dim con1 As New ADODB.Connection
Dim rec1 As New ADODB.Recordset
Dim str As String

Private Sub Command1_Click()



Text15.Visible = True
Text16.Visible = False
Set Text1.DataSource = rec
Text1.DataField = "ID"
Set Text2.DataSource = rec
Text2.DataField = "name"
Set Text3.DataSource = rec
Text3.DataField = "mob"
Set Text4.DataSource = rec
Text4.DataField = "email"
Set Text5.DataSource = rec
Text5.DataField = "add"
Set Text6.DataSource = rec
Text6.DataField = "city"
Set DataGrid1.DataSource = rec
Set Text7.DataSource = rec
Text7.DataField = "event"
Set Text8.DataSource = rec
Text8.DataField = "date"
Set Text9.DataSource = rec
Text9.DataField = "cate"
Set Text10.DataSource = rec
Text10.DataField = "deco"
Set Text11.DataSource = rec
Text11.DataField = "person"
Set Text12.DataSource = rec
Text12.DataField = "chat"
Set Text13.DataSource = rec
Text13.DataField = "chaina"
Set Text14.DataSource = rec
Text14.DataField = "catebill"
Set Text15.DataSource = rec
Text15.DataField = "hallpr"

'rec.Close
End Sub

Private Sub Command2_Click()

Text15.Visible = False
Text16.Visible = True
Set Text1.DataSource = rec1
Text1.DataField = "ID"
Set Text2.DataSource = rec1
Text2.DataField = "name"
Set Text3.DataSource = rec1
Text3.DataField = "mob"
Set Text4.DataSource = rec1
Text4.DataField = "email"
Set Text5.DataSource = rec1
Text5.DataField = "add"
Set Text6.DataSource = rec1
Text6.DataField = "city"
Set DataGrid1.DataSource = rec1
Set Text7.DataSource = rec1
Text7.DataField = "event"
Set Text8.DataSource = rec1
Text8.DataField = "date"
Set Text9.DataSource = rec1
Text9.DataField = "cate"
Set Text10.DataSource = rec1
Text10.DataField = "deco"
Set Text11.DataSource = rec1
Text11.DataField = "person"
Set Text12.DataSource = rec1
Text12.DataField = "chat"
Set Text13.DataSource = rec1
Text13.DataField = "chaina"
Set Text14.DataSource = rec1
Text14.DataField = "catebill"
Set Text16.DataSource = rec1
Text16.DataField = "lawnpr"

'rec1.Close

End Sub

Private Sub Command3_Click()
If Text1.Text = "" Or Text2.Text = "" Or Text3.Text = "" Or Text4.Text = "" Or Text5.Text = "" Or Text6.Text = "" Or Text7.Text = "" Or Text8.Text = "" Or Text9.Text = "" Or Text10.Text = "" Or Text11.Text = "" Or Text12.Text = "" Or Text13.Text = "" Or Text14.Text = "" Then
MsgBox "Some Field are empty Please Try again..!!", vbAbortRetryIgnore
Else

MsgBox "Are You Sure to Delete the Record..!", vbCritical, "Error"
rec.Delete
rec1.Delete
End If
End Sub

Private Sub Command4_Click()
rec.Close
rec1.Close
Unload Me
End Sub



Private Sub Form_Load()
Form13.Refresh
con.Open "Provider=Microsoft.Jet.OLEDB.4.0;Data Source=" & App.Path & "\database.mdb;Persist Security Info=False;"
con.CursorLocation = adUseClient
rec.Open "select * from bookhall", con, adOpenDynamic, adLockOptimistic

con1.Open "Provider=Microsoft.Jet.OLEDB.4.0;Data Source=" & App.Path & "\database.mdb;Persist Security Info=False;"
con.CursorLocation = adUseClient
rec1.Open "select * from booklawn", con, adOpenDynamic, adLockOptimistic

End Sub


This post has been edited by andrewsw: 06 January 2020 - 06:00 AM
Reason for edit:: removed please help me..! fluff from title


Is This A Good Question/Topic? 0
  • +

Replies To: I am facing one issue related to recordset object

#2 andrewsw   User is offline

  • palpable absurdity
  • member icon

Reputation: 6898
  • View blog
  • Posts: 28,550
  • Joined: 12-December 12

Re: I am facing one issue related to recordset object

Posted 06 January 2020 - 05:24 AM

What line raises the error?
Was This Post Helpful? 0
  • +
  • -

#3 siddhesh003   User is offline

  • New D.I.C Head

Reputation: 0
  • View blog
  • Posts: 4
  • Joined: 06-January 20

Re: I am facing one issue related to recordset object

Posted 06 January 2020 - 05:29 AM

line 109 : con.Open "Provider=Microsoft.Jet.OLEDB.4.0;Data Source=" & App.Path & "\database.mdb;Persist Security Info=False;"
when i reopen that page

do u get my issue even i dont know how can i explain it.
Was This Post Helpful? 0
  • +
  • -

#4 andrewsw   User is offline

  • palpable absurdity
  • member icon

Reputation: 6898
  • View blog
  • Posts: 28,550
  • Joined: 12-December 12

Re: I am facing one issue related to recordset object

Posted 06 January 2020 - 05:41 AM

It seems that the connection is already open. You should probably check whether it is already open before attempting to open it a second time (and/or close it when you no longer need it).

You do not need two connections pointing to the same database, con and con1. I would probably resolve this first.
Was This Post Helpful? 0
  • +
  • -

#5 siddhesh003   User is offline

  • New D.I.C Head

Reputation: 0
  • View blog
  • Posts: 4
  • Joined: 06-January 20

Re: I am facing one issue related to recordset object

Posted 06 January 2020 - 05:50 AM

can we communicate on email ?? here i am not able to attact document

i got the point that i dont have to reconnect database when it is already connected by con variable but now i deleted 2nd connection string and also closed the recordset object in "back button" which is used for unloading page even same issue is showing.

[email protected] my email. please email me if u want to i have to submit this project in college as my final year project
Was This Post Helpful? 0
  • +
  • -

#6 andrewsw   User is offline

  • palpable absurdity
  • member icon

Reputation: 6898
  • View blog
  • Posts: 28,550
  • Joined: 12-December 12

Re: I am facing one issue related to recordset object

Posted 06 January 2020 - 05:59 AM

No thanks, use the forum. Especially as other members are more willing and able to assist with VB6 questions (although you may have to wait a while). VB6 is long defunct.

I searched "adodb.connection is open" to discover that you can check its State before attempting to Open.

If you have edited your code then post the revised code.
Was This Post Helpful? 1
  • +
  • -

#7 siddhesh003   User is offline

  • New D.I.C Head

Reputation: 0
  • View blog
  • Posts: 4
  • Joined: 06-January 20

Re: I am facing one issue related to recordset object

Posted 06 January 2020 - 06:02 AM

this is the back button on which i am closing the recordset varible
[code]Private Sub Command4_Click()
rec.Close
rec1.Close
Unload Me
End Sub


this is the form load event
Private Sub Form_Load()
Form13.Refresh
con.Open "Provider=Microsoft.Jet.OLEDB.4.0;Data Source=" & App.Path & "\database.mdb;Persist Security Info=False;"
con.CursorLocation = adUseClient
rec.Open "select * from bookhall", con, adOpenDynamic, adLockOptimistic


rec1.Open "select * from booklawn", con, adOpenDynamic, adLockOptimistic

End Sub
Was This Post Helpful? 0
  • +
  • -

#8 andrewsw   User is offline

  • palpable absurdity
  • member icon

Reputation: 6898
  • View blog
  • Posts: 28,550
  • Joined: 12-December 12

Re: I am facing one issue related to recordset object

Posted 06 January 2020 - 10:01 AM

What happened to code tags?

If you are getting the same error then I have already described what you probably need to do.
Was This Post Helpful? 0
  • +
  • -

Page 1 of 1