I'm switching our ASP code to use SQL Native Client so that we can connect to a mirrored database with a failover partner, since you can only supply the failover partner parameters in SQL Native Client. When I run a proc that returns an nvarchar(max) column with Driver={SQL Server} everything works fine. When I run procs that return small colums with Driver={SQL Server Native Client 10.0} that works fine. It's only when I try to run a proc that returns an nvarchar(max) column while using Driver={SQL Server Native Client 10.0}; that I get the error. The error happens as soon as we hit
rs.Open cmdTemplate
So I'm not even referring to the column. Setting the conn string like this:
if bUseSQLNative then
connString = "Driver={SQL Server Native Client 10.0}; Network=DBMSSOCN; server=" & rs("SERVER_NAME") & "," & rs("PORT_NUM") & ";database=" & rs("DATABASE_NAME")
connString = connString & ";uid=" & rs("USER_NAME") & ";pwd=" & UnProtectValueEx(ConnSaltForDBPwd(), rs("CONNECTION_NAME"), rs("PASSWORD"))
else
connString = "Driver={SQL Server}; Network=DBMSSOCN; server=" & rs("SERVER_NAME") & "," & rs("PORT_NUM") & ";database=" & rs("DATABASE_NAME")
connString = connString & ";uid=" & rs("USER_NAME") & ";password=" & UnProtectValueEx(ConnSaltForDBPwd(), rs("CONNECTION_NAME"), rs("PASSWORD"))
end if
connString = connString & ";"
And opening like this:
set rs = server.CreateObject("ADODB.RecordSet")
rs.CursorLocation = 3
rs.CursorType = 3
rs.CacheSize = 50
on error resume next
rs.Open cmdTemplate
The error is: Microsoft Cursor Engine (0x800A0001) Data provider or other service returned an E_FAIL status.
I found it. I had to use
connString = "Provider=SQLNCLI10; DataTypeCompatibility=80;...
The DataTypeCompatibility makes the nvarchar max etc map back to formats ado can handle. And for some reason that parameter doesn't take effect with Driver={SQL Server Native Client 10.0};, only with Provider=SQLNCLI10