Mike,
I don't think you can return it as a OUTPUT parameter, but rather a field as part of the returning Recordset.
ie:
Main Topics
Browse All TopicsHello everyone,
I'm having a little bit of an issue and need a some help.
Here's the situation. I have an Access database (2003) which connects to SQL Server 2005 using ADO 2.8. I just finished giving them the capability to send HTML emails and that works great as long as the email isn't over 8000 characters. Well guess what, they want to send one today which is just over 11000 characters.
I have a procedure that takes their email and embeds it between the company header and footer and then sends it back to them so they can view it on the client before sending. I have no problem sending up an email that is larger than 8K using the adLongVarWChar when I create the parameter. My problem is in the output parameter. If I set it to adLongVarWChar, I get an error telling me that the datatype is a deprecated large datatypes and that they can't be used as output parameters.
How do I return my VARCHAR(MAX) from my command object?
I did a little reading and came across this wonderful paper from Microsoft and thought it was the answer to my prays, but low and behold, it doesn't seem to work. (http://msdn2.microsoft.co
I've modified my connection string to use the SQL Native Client and set the compatibility flag but it still doesn't work.
Here is my code.
With cmdTemp
.ActiveConnection = cn
.CommandText = "pEmailCustomMailingView"
.CommandType = adCmdStoredProc
'.Parameters.Refresh
.Parameters.Append .CreateParameter("@strProj
.Parameters.Append .CreateParameter("@strSubj
.Parameters.Append .CreateParameter("@strHTML
.Parameters.Append .CreateParameter("@strProc
.Parameters.Append .CreateParameter("@strHTML
Set rstTemp = .Execute
Debug.Print rstTemp.RecordCount
End With
I'm heading out of the office, but will be back in a few hours to try and wrap this up and upload the new version for them. I have to catch a plane in the morning.
Thanks in advance,
Mike
This Question has been solved and asker verified All Experts Exchange premium technology solutions are available to subscription members.
Experts Exchange has been collecting answers to technology questions since 1996…3 million and counting! If you have a question, chances are we already have your answer.
If you can't find the exact answer you're looking for, ask our exclusive community of 50,000 experts. You’ll get a personalized answer from a trusted professional.
Thousands of free tech tips, tricks, how-to’s and tutorials are available in our peer reviewed articles section. See for yourself how smart our experts are, no login required.
Access the answers to your technology questions today.
30-day free trial. Register in 60 seconds.
Members of the expert community talk about why the experience at Experts Exchange is different than what you will find anywhere else.

Try it out and discover for yourself.
30-day free trial. Register in 60 seconds.
Join the community of experts here and help other tech pros by answering question in your area of expertise. You can earn FREE access to all Experts Exchange's premium features and resources.
Sorry,
I tried using ADO 2.8 & SQL Server Native Client 10.0 but same problem is there. It is not returning nVarChar(Max) or VarChar(Max) to outparameters whoes type adLongVarChar OR adLongVarWChar.
I know that if we return recordset it returns value, but returnin single record value through ADO parameters is so much faster then recordset appx. 10 times in Local Area Network or over internet.
Please view my code and help me for solution.
Sanjay Shah
Sanjay,
Are you sure the recordset is that much slower? That has not been my experience. You can still use the command object. Just assign the .Execute to a recordset object and modity your proc to return a single record. When creating your ADO recordset, make sure it is set to snapshot, forwardonly, readonly, ,etc.
My solution with the recordset has worked perfectly for years now.
Do no quote me on this, but the problem with returning nvarchar(max) from a proc with ADO is that ADO 2.8 came out before the 'max' datatype and I'm not sure that the ADO knows how to handle it. Just my two cents.
Regards,
Mike
Yes Mike,
Returning Single Record Recordset Value to output parameters is appx. 10 times faster then returning recordset. I tried returning recordset it is working fine. But in case of remote connection through internet speed is important. I tried to return single recordset through internet whose fields is more than 125 & recordset length is over 1500 bytes (excl. Memo nVarChar) it then takes avg. 2 seconds but if I return through parameters it takes 0.14 seconds.
You also try this.
Regds.
Sanjay Shah
Business Accounts
Answer for Membership
by: chapmandewPosted on 2008-03-06 at 14:23:47ID: 21065414
Dim cn As New ADODB.Connection
atibility= 80;MARS Connection=True;" m1", adLongVarWChar, adParamInput, -1, str)
m/MSDN/Sho wPost.aspx ?PostID=30 8037& SiteI D=1
Dim cmd As New ADODB.Command
Dim rs As New ADODB.Recordset
Dim str As String
cn.Open "Provider=SQLNCLI;Data Source=.;Integrated Security=SSPI;DataTypeComp
cn.Execute "create procedure testproc(@paramin nvarchar(max)) as begin select @paramin end"
cmd.ActiveConnection = cn
cmd.CommandType = adCmdStoredProc
cmd.CommandText = "testproc"
str = "testing !!!! testing !!!! testing !!!! testing !!!! testing !!!! testing !!!! testing !!!! testing !!!! testing !!!! testing !!!! testing !!!!"
cmd.Parameters.Append cmd.CreateParameter("@para
Set rs = cmd.Execute
MsgBox rs.Fields(0).Value
cn.Execute "drop procedure testproc"
Set cmd = Nothing
cn.Close
here is a link to an msdn article on it
http://forums.microsoft.co