Showing posts with label references. Show all posts
Showing posts with label references. Show all posts

Thursday, March 22, 2012

Class Reference - Constructor with Arguments?

From the references tab, I see I can create an instance reference, but I do
not see how I can instantiate that class with a constructor that has
arguments. Does it only do the default New() constructor?
I would like something like: m_MyClass = New MyClass(Version as Integer)I have not found a way to do this. I will perform further research on it
and update you once I have more information.
Sincerely,
William Wang
Microsoft Online Partner Support
When responding to posts, please "Reply to Group" via your newsreader so
that others may learn and benefit from your issue.
This posting is provided "AS IS" with no warranties, and confers no rights.|||Hi David,
In the Reference tab of report properties, if we specify a instance name we
can only use the default constructor. If you need something other than the
default constructor, you can instantiate the class in the <Code> property
of the report instead. You'll need to reference the assembly on the
References tab of the report properties, but you would't declare an
instance there.
Instead, you'd declare the instance and initialize it in the Code property:
For example,
Dim m_myClass As MyClass
Protected Overrides Sub OnInit()
m_myClass = new MyClass(1234)
End Sub
Sincerely,
William Wang
Microsoft Online Partner Support
When responding to posts, please "Reply to Group" via your newsreader so
that others may learn and benefit from your issue.
This posting is provided "AS IS" with no warranties, and confers no rights.

Sunday, February 19, 2012

Checking if column exists

Without throwing an error, how can I check if a column exists before
performing some action that references the column in question?You can do:
IF EXISTS ( SELECT * FROM INFORMATION_SCHEMA.COLUMNS
WHERE COLUMN_NAME = @.col AND TABLE_NAME = 'tbl' )
Another option is to use the metadata functions like COL_LENGTH or
COLUMNPROPERTY. Use any argument and if it returns NULL then you can
conclude the column does not exist. See SQL Server Books Online for the
various arguments you can use for these functions.
Anith|||Thanks
"Anith Sen" wrote:

> You can do:
> IF EXISTS ( SELECT * FROM INFORMATION_SCHEMA.COLUMNS
> WHERE COLUMN_NAME = @.col AND TABLE_NAME = 'tbl' )
> Another option is to use the metadata functions like COL_LENGTH or
> COLUMNPROPERTY. Use any argument and if it returns NULL then you can
> conclude the column does not exist. See SQL Server Books Online for the
> various arguments you can use for these functions.
> --
> Anith
>
>