Level Extreme platform
Subscription
Corporate profile
Products & Services
Support
Legal
Français
ADO and OUTPUT nText/Text parameter for Stored Procs
Message
General information
Forum:
Visual FoxPro
Category:
Databases,Tables, Views, Indexing and SQL syntax
Environment versions
Visual FoxPro:
VFP 9
OS:
Windows Server 2003
Network:
Windows 2000 Server
Database:
MS SQL Server
Miscellaneous
Thread ID:
00978730
Message ID:
00978957
Views:
92
Rick,

I don't have a real answer, but I did run into an issue, but haven't been able to completely write it up to send to Microsoft, where an ntext column is treated vastly different than a nchar/nvarchar column by the CursorAdapter. I had to perform a cast() from ntext to nvarchar in the SQLCommand: cast( msgtext as nvarchar(4000) ) as msgtext. This was in VFP8 I've not been able to run the test in the RTM VFP9.

>I have a problem calling a stored procedure in SQL Server where there's an OUTPUT parameter that is of type nText. I can't seem to figure out how to pass this parameter as nText to the server - it can pass as nVarChar with no problem, but not as nText.
>
>The stored proc looks like this:
>
>
>CREATE PROCEDURE test
>  @cName nText OUTPUT,
>  @bBit as bit,
>  @iResult int OUTPUT
>AS
>
>Set @iResult = 10
>GO
>
>
>actually come to think of it I'm not sure how SET an nTEXT value to be used as an output parameter since you can't assign nText - you can only query for it, but SQL Server supports this (http://msdn.microsoft.com/library/default.asp?url=/library/en-us/tsqlref/ts_create_4hk5.asp) if anybody knows how to set this let me know. I'm doing this for some generic code so it needs to work with any type hence the question.
>
>The code to call it is here:
>
>
>FUNCTION ADOStoredProcedure()
>
>SYS(3101,65001)
>
>LOCAL oConn as ADODB.Connection
>oConn = CREATEOBJECT("ADODB.Connection")
>oConn.ConnectionString = THIS.cAdoConnectionString
>oConn.Open()
>
>LOCAL oCommand as ADODB.Command
>oCommand = CREATEOBJECT("ADODB.Command")
>oCommand.CommandType= 4  && Stored Proc
>oCommand.ActiveConnection = oConn
>oCommand.CommandText = "TEST"  && Stored Proc name
>
>*** Or wrappered
>LOCAL oParameter as ADODB.Parameter
>oParameter = CREATEOBJECT("ADODB.Parameter")
>oParameter.Type= 203  && adVarWChar
>oParameter.Value = "English"
>oParameter.Size = 90000000
>oParameter.Direction = 3  && Fails with 3 but works with 1
>oCommand.Parameters.Append(oParameter)
>
>*this.AdoAddParameter(oCommand,"English","Name","OUT",203)
>this.AdoAddParameter(oCommand,.t.,"BitParm")
>this.AdoAddParameter(oCommand,0,"nResult","OUT")
>
>lnAffected=0
>? oCommand.Execute(@lnAffected,,128)     && No result set
>
>*** Gets unspecified error
>
>SYS(3101,0)
>RETURN
>
>
>AdoAddParameter() is just a wrapper around the Parameter object to simplify adding parameters. I use the parm object explictly for the nText parm to make it obvious what's being set.
>
>The code above fails with Unspecified error - it never hits SQL Server, but seems to fail inside of ADO. If I change the parameter type to nVarChar(202) and set the size to 4000 the call works fine. It also works with nText as an IN parameter.
>
>It looks like ADO is not allowing this call to go through... Does anybody know if this is not supported?
df (was a 10 time MVP)

df FoxPro website
FoxPro Wiki site online, editable knowledgebase
Previous
Next
Reply
Map
View

Click here to load this message in the networking platform