Friday, March 23, 2012

How to use SqlFacet in VB .Net (for parameters)

I have written a CLR stored proc in VB .NET and I have to define the length of the string to be passed as parameters. I cannot get it to compile in VB .Net (VS 2005). pl help.

Code Snippet

<Microsoft.SqlServer.Server.SqlProcedure()> _

Public Shared Sub ProcessAdjustment(ByVal ServerName As String, ByVal Cob As SqlString <SqlFacetAttribute(MaxSize=30)> , Optional ByVal DateFrom As String = Nothing, Optional ByVal DateTo As String = Nothing)

Thanks in Advance,

Arun

I assume you want to apply the SqlFacetAttribute to your Cop param?

If so, shouldn't the attribute be before the param (that's the way it is in C# anyway). Also, in VB I believe you're using the := syntax for attribute properties:

<SqlFacet(MaxSize:=30)> ByVal Cob as SqlString

You have to excuse me but my VB.NET syntax is a bit rusty.

Niels
|||

Thanks Niels.

Works perfectly.

No comments:

Post a Comment