Forum Discussion
def Get_Available_Customer_Details_Not_Linked_To_Asset() :
customer= executeQuery("SELECT TOP 1 [Number], [Name] FROM [dbo].[Asset] WHERE [Id] NOT IN (SELECT DISTINCT [AssetId] FROM [dbo].[Asset] WHERE [AssetId] IS NOT NULL)");
for customer in customers :
AssetNumber = customer["Number"]
AssetName = safe["Name"]
AssetDetails = f"{AssetNumber} {AssetName}"
return assetDetails
Log.Error("No available asset exists!");
I don't see ADO usage, in the coding that you have provided? There should be something like,
def TestProc():
Cmd = ADO.CreateADOCommand()
Cmd.ConnectionString = "Provider=Microsoft.Jet.OLEDB.4.0;" + \
'Data Source=C:\\Users\\Public\\Documents\\TestComplete 14 Samples\\Desktop\\Checkpoints\\XML\\DataGridViewSample\\OrdersDB.mdb'
Cmd.CommandText = 'SELECT * FROM orders WHERE orders.[state] = 2'
# etc
- ElizabethO3 days agoOccasional Contributor
def executeQuery(queryString, queryParameterListOfDictionary = []) : query = ADO.CreateADOQuery(); try : query.ConnectionString = getDbConnectionString(); query.SQL = queryString; # Map query parameters and values. for queryParameter in queryParameterListOfDictionary : for key, value in queryParameter.items() : query.Parameters.ParamByName(key).Value = value; query.Open(); results = convertQueryToListOfDictionaries(query); return results; except Exception as e: Log.Error(str(e)); finally : closeDbConnection(query);Here it is
- rraghvani3 days ago
Champion Level 3
I'm struggling to replicate what you have provided. I don't know what convertQueryToListOfDictionaries(query) and closeDbConnection(query); is doing.
I've made 100 calls to my SQL database to retrieve "Name" from dbo.tbl_Schemes table, by constantly opening, querying and closing without issues.
You need to verify that your data is correctly retrieved, and that you are correctly closing the connection.
- ElizabethO1 day agoOccasional Contributor
def convertQueryToListOfDictionaries(query) : query.First(); listOfDictionaries = []; while not query.EOF : record = []; for number in range(0, query.FieldCount) : record.append((query.Field[number].FieldName,query.Field[number].Value)); listOfDictionaries.append(dict(record)); query.Next(); return listOfDictionaries;Its just returning a list, When I added from tc import * it fixed it for a bit but now its started again, might go with the option of downgrading my TC version