Connection to DB not closing properly?
- Bookmark
- Subscribe
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
11-06-2018
10:20 AM
11-06-2018
10:20 AM
Connection to DB not closing properly?
I have this function that accesses a database using ADODriver. I have it closing the connection at the end, and the first run through the function when I open TC passes. However, on a subsequent run, TestComplete will crash because the connection is still open. I'm not sure what I am missing. Can anyone help? I did notice, as I got to "countTable.ADOConnectionObject." that the auto-extension table didn't display for me to choose the Close() property, so I did type that manually.
def getTableValues():
num = []
countTable = DDT.ADODriver(ConStr, query) while not countTable.EOF(): num.append(countTable.Value[1]) countTable.Next() for i in num: Log.Message(i) countTable.ADOConnectionObject.Close()
1 REPLY 1
- Bookmark
- Subscribe
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
11-06-2018
11:49 AM
11-06-2018
11:49 AM
A better way of closing it is to actually close the DDT driver. This is a more complete way. I'm not fully familiar with Python syntax but this is what it should look like.
def getTableValues(): num = [] countTable = DDT.ADODriver(ConStr, query) while not countTable.EOF(): num.append(countTable.Value[1]) countTable.Next() for i in num: Log.Message(i) DDT.CloseDriver(countTable.Name)
Robert Martin
[Hall of Fame]
Please consider giving a Kudo if I write good stuff
----
Why automate? I do automated testing because there's only so much a human being can do and remain healthy. Sleep is a requirement. So, while people sleep, automation that I create does what I've described above in order to make sure that nothing gets past the final defense of the testing group.
I love good food, good books, good friends, and good fun.
Mysterious Gremlin Master
Vegas Thrill Rider
Extensions available
