teemu_selkala
13 years agoOccasional Contributor
Unable to store database tablet values to excel
Hi,
I have (again) a problem :) - sorry for flooding the forums. I have a scenario where I have a large set of SQL queries stored in an excel. I would like to run through them and store the values to a new excel but I feel quite dump since I seemingly cannot get a working solution how to get all those tables from DB stored up for saving. Code follows... code runs but I don't get anything when I try to log the results - any hints, should i resturcture completely or anything really is appriachiated a lot :).
I have (again) a problem :) - sorry for flooding the forums. I have a scenario where I have a large set of SQL queries stored in an excel. I would like to run through them and store the values to a new excel but I feel quite dump since I seemingly cannot get a working solution how to get all those tables from DB stored up for saving. Code follows... code runs but I don't get anything when I try to log the results - any hints, should i resturcture completely or anything really is appriachiated a lot :).
function checkout()
{
var Excel = Sys.OleObject("Excel.Application")
var searchSQL
var result =""
Excel.Workbooks.Open("c:\\MyExcel.xlsx")
var RowsCount = Excel.ActiveSheet.UsedRange.Rows.Count;
Log.Message(RowsCount)
for(i=1;i<RowsCount;i++)
{
searchSQL = Excel.Cells(i,1);
result = result + RunQuery(searchSQL);
}
RecSet = result;
RecSet.Save("c:\\MyAnother.xml",1)
Excel.Quit()
}
function RunQuery(aSQL)
{
var Conn;
Conn= ADO.CreateConnection()
Conn.ConnectionString="my connection string";
Conn.Open();
Cmd = ADO.CreateCommand();
Cmd.ActiveConnection = Conn;
Cmd.CommandType = adCmdText;
Cmd.CommandText = VarToStr(aSQL)
RecSet = Cmd.Execute();
var Result = RecSet
Log.Message(RecSet)
Conn.Close();
return(Result);
}