sql server 2008 - Excel ADO Recordset Open Fails no error -


the following sql works sql server 2008 r2 query tools in excel ado rs closed after call rs.open... on error set error not happened on rs.open on check rs.eof "recordset closed" message thrown. con open , works other rs.open calls.

the sql bit complex , may ado not handling it. sql builds csv list of facility_ids. sql works in ado.net.

is there missing/ or ado incapable of dealing multi-statement sql?

    sql = "declare @tmp varchar(250);" & vbcrlf _      & " set @tmp = '';" & vbcrlf _      & " " _      & " select @tmp = @tmp + ltrim(facility_id) + ', '" _      & "  facility_ei" _      & " cover_letter = '" & scategory & "'" _      & " order facility_id;" & vbcrlf _      & " " _      & " select substring(@tmp, 1, len(@tmp)-1);"     rs.open sql, con     if rs.eof         msgbox "category lookup failed: " & scategory         goto local_exit     end if     sfacidlist = rs(0) ' list of facilities in category     rs.close 

here cleaned sql - modify first select use table testing:

declare @tmp varchar(250); set @tmp = ''  select @tmp = @tmp + ltrim(facility_id) + ', '  facility_ei cover_letter = 'at&t bugs' order facility_id  select substring(@tmp, 1, len(@tmp)-1) csv_list 


Comments

Popular posts from this blog

javascript - jQuery: Add class depending on URL in the best way -

caching - How to check if a url path exists in the service worker cache -

Redirect to a HTTPS version using .htaccess -