Forum Discussion
- NisHeraValued Contributor
- karthick7Contributor
try
{
//var excelName = "C:\\TestData.xls"
var excelFileName = "Test"
var excelConnection = new Sys.OleObject("ADODB.Connection");
var str_Connection = "Provider=Microsoft.Jet.OLEDB.4.0;Data Source = " + excelFileName + ";Persist Security Info=False;Extended Properties=Excel 8.0;"
excelConnection.Open(str_Connection);
var excel_recordSet = new Sys.OleObject("ADODB.Recordset");
var excelQuery = select * from login;(example)
excel_recordSet.Open(excelQuery, excelConnection);
if(!excel_recordSet.bof)
{
try
{
resultValue = aqConvert.VarToStr(excel_recordSet.fields.Item(ColumnName));
}
catch(e)
{
resultValue = undefined;
}
}
excel_recordSet.Close();
excelConnection.Close();- tristaanogreEsteemed Contributor
karthick7's solution doesn't relate to the OP. NisHera has the correct documentation for doing a direct to DB ADO connection.
If you intend to do something more on the lines of looping through a set of data records, you could use the DDT.ADODriver
- Colin_McCraeCommunity Hero
I'm in agreement with NisHera and tristaanogre. (also that karthick7's answer has nothing to do with the question!)
Also worth adding that if you're not sure about the connection string, speak to the development team rather than trying to guess. It's their database and they should understand, and so be able to tell you, it's connection requirements.
Also, make sure you have the 32 bit drivers installed. See the note here: https://support.smartbear.com/testcomplete/docs/testing-with/advanced/working-with-external-data-sources/databases/index.html
Related Content
- 10 years ago
Recent Discussions
- 3 days ago
- 3 days ago
- 6 days ago