TESTHR(pConn.CreateInstance(__uuidof(Connection)));
TESTHR(pRS.CreateInstance(__uuidof(Recordset)));

try
{
pConn->Open("Provider=sqloledb;Data Source=Sydney;"
"Initial Catalog=radio;User Id=sa;Password=f1ng3rs;","","",adConnectUnspecified);
pRS->PutRefActiveConnection(pConn);
pRS->Open("SELECT artistname, albumname, songname, fileLocationASF, fileLocationRA, songID FROM song WHERE uploadedToISP=0 ORDER BY songID DESC;",
vtMissing, adOpenForwardOnly, adLockReadOnly, adCmdText);


while (!pRS->adoEOF)
{
vtArtist = pRS->Fields->GetItem((long)0)->GetValue();
vtAlbum = pRS->Fields->GetItem((long)1)->GetValue();
vtSong = pRS->Fields->GetItem((long)2)->GetValue();
vtFileLocationASF = pRS->Fields->GetItem((long)3)->GetValue();
vtFileLocationRA = pRS->Fields->GetItem((long)4)->GetValue();
vtSongID = pRS->Fields->GetItem((long)5)->GetValue();

strBuff.Format("%s - %s - %s", (char*)((_bstr_t)vtArtist), (char*)((_bstr_t)vtAlbum), (char*)((_bstr_t)vtSong));
BSTR bstrFilename = strBuff.AllocSysString();
if (ftpUploadFile(bstrFilename, m_strFTPServername, (char*)((_bstr_t)vtFileLocationASF), (char*)((_bstr_t)vtFileLocationRA), m_strFTPASFRoot, m_strFTPRARoot))
{
strBuff.Format("radioUpdateUploadedToISP %li", vtSongID.lVal);
//AfxMessageBox(strSQL);
BSTR bstrSQL = strBuff.AllocSysString();
pConn->Execute(bstrSQL, NULL, adExecuteNoRecords);
SysFreeString(bstrSQL);
pRS->MoveNext();
}
SysFreeString(bstrFilename);
}
pRS->Close();
pConn->Close();
}
catch (_com_error)
{

}