EXCEL 2013 VBA Querying two files on separate databases on different servers at same time -


I have only a moderate experience when I come to Excel VBA and ADO. I have two files in a task file and calendar file Each has a different database and on a different server, it is necessary to determine the number of actual work days associated with the work. Therefore, check against the calendar file to determine the timestamp date from the work file. How many days are the actual day in work I came to know how to open two different database connections in my VBA script, but I do not know how to combine two files, so I can get count of working days

Like

  Select Taskid, Count (*) TaskFile, from the calendar where TaskDate & gt; = CalendarDate and CalendarWorkDay = 1 group by Taskid; = CalendarDate and TaskDate   

I thought of preloading a worksheet with calendar data, but do not know how the query will work.

Any suggestions or code snippets will be highly appreciated.

This is a quick and filthy sub-routine that, like the suggested things in the above other comment Will do something. It probably will not work properly as you need to correct it from the box, but the overall idea is sound just realizing that every record in the first query will generate a new query for the second file / database, so there may be a lot of tigers If there are too many records. sub-two recorders (objConn) as the ADODB.Connection, objConn2 ADODB.Connection dim RS ADODB.Recordset dim strSQL as strring string strConn string, as the strconn2 string 'open Set the first connection as objConn = new ADODB.Connection strConn = "& lt, set your connection to 1 connection string," ObjConn.Open strConn "Open objConn2 = new ADODB.Connection strconn2 = "& Lt; your second connection string & gt;" ObjConn2.Open strconn2 'first query: strSQL = "Taskid, TaskDate Select TaskID by TaskFile Group by opening' first query set using first 'recordset = new ADODB.Recordset rs.Open strSQL, objConn' see if die Any record returned then.EOF and R.B.F. Then exit all the End if you create a SQL statement to 'make the recordset r.MoveFirst do rs.EOF' second bit by looting. DB strSQL = "On the basis of selection number (*), the port with the quotation marks and date formats can be in the form of a record-port from the port where '& amp; Rs.Fields (" taskdate "). Value & amp; '& Gt; = Calendar day and '' & amp; Rs.Fields ("taskdate"). Value & amp; "'& Lt; = CalendarDate and CalendarWorkDay = 1"' '. Retrieve your solution from heresYourAnswer = rs2.Fields ("RecordCount") value 'open recordset set RS2 = new ADODB.Recordset rs2.Open strSQL, objConn2 repeat next to RSR in the main loop and sub

Comments

Popular posts from this blog

php - PDO bindParam() fatal error -

logging - How can I log both the Request.InputStream and Response.OutputStream traffic in my ASP.NET MVC3 Application for specific Actions? -

java - Why my included JSP file won't get processed correctly? -