Forum Discussion
Look at the TC examples here: http://support.smartbear.com/viewarticle/56911/
Using the ADO object works fine for me. In the exxample below I pass in a SQL query. I have another function that builds SQL queries for me to pass into this..
function query (sqlQuery) {
var dbObj = ADO.CreateADOQuery();
dbObj.ConnectionString = //your connection string here
dbObj.SQL = sqlQuery;
dbObj.Open();
queryResult = dbObj;
return queryResult;
}
- chrisb10 years agoRegular Contributor
And for help building your connection string: http://www.connectionstrings.com/
- jasmeenkaur278 years agoContributor
I tried the same code as stated:
var Qry1;
// Create a query
Qry1 = ADO.CreateADOQuery();
// Specify the connection string
Qry1.ConnectionString = "Driver={Microsoft ODBC for Oracle};Dbq= FILCODU2.uk.fid-intl.com:1701/FILCODU2;Uid=xx;Pwd=xx;"
// Specify the SQL expression
Qry1.SQL = "Select * FROM table WHERE COMM_CODE = 'COT'";
// Execute the query
Qry1.Open();
// Process results and insert data into the test log
Qry1.First();
while (!Qry1.EOF) {
Log.Message(Qry1.FieldByName("columnname").Value);
Qry1.Next();
}
// Closes the query
Qry1.Close();
- gvkr198510 years agoOccasional Contributor
here is my code and it is not working...
Sub SQLServer
Set dbObj = ADO.CreateADOQuery()
dbObj.ConnectionString = mil-tfsprd-01
dbObj.Open()End Sub
- chrisb10 years agoRegular Contributor
You are not doing any SQL query on the database! In the example below I have hardcoded a generic SQL query in for you to modify, you would most likely want to add a parameter to your function and pass the query in, but this should do for now.
Sub SQLServer
Set dbObj = ADO.CreateADOQuery()
dbObj.ConnectionString = mil-tfsprd-01dbObj.SQL = "Select * FROM yourcolumn WHERE avalue = something";
dbObj.Open()End Sub
Your connection string looks odd, take a look at the link I posted above. That site has lots of information about how a connection string should be formatted. Check with your app developers they may well know the correct connection string if your app is having to connect to the database.
Related Content
- 3 years ago
Recent Discussions
- 14 hours ago