Showing posts with label custom. Show all posts
Showing posts with label custom. Show all posts

Friday, March 30, 2012

Regarding Custom Code using table or list control(data set)

I have the report like this

list1

{

list2

{

table1

table header

table fields

table footer

}

}

now i want to calculate the sum of one field in table when it contains particular value using CUSTOM CODE ONLY

and i want to display it in table footer. please send me answer to this id as soon as possible.

Thanks

Sateesh Maduri

Maybe I'm missing something, but couldn't you just use a conditional aggregation expression like the following in the table footer:

=Sum(iif(Fields!A.Value = "abc", CInt(Fields!B.Value), 0))

-- Robert

|||

Hello Robert

Actually I already know that what u have given using sum().But I need Custom Code for that ,I mean if I have a dataset which fills the data in the table control How should I write Custom Code to calculate sum of one field when it contains particular value.

Thanks

sql

Regarding Custom Code

Hello

I have report like this

list1

list2(includes in list1)

table (includes in list2)

end of list2

end of list1

Now I want to calculate the sum of one column in table when it contains particular value and I want to display in table footer . I already know using sum() fuction.I want to know using custom code calculation for the above problem(How Can I repeat my data set in Custom code function for each row). So , If anyone knows Please reply.

It's Very Urgent

Thanks

Have a look at these

http://forums.microsoft.com/MSDN/ShowPost.aspx?PostID=541699&SiteID=1

http://blogs.msdn.com/bwelcker/archive/2005/05/10/416306.aspx

Wednesday, March 21, 2012

Referential integrity during replication

Hello forum

I like to build a custom replication application for a databasee.
To questions concering this. The idea is to use a mechanim, which updates table by table (in sequence).

During the replication proccess I update a table (table1), which has 1 to 1 refenceto a second table(table2). This new record is unsing a reference which hasn't been entered by this time into table 2. This is hurts the referencial integrity, right?

Would it help to use a transaction for the update in table 1 and table 2, when is the integrity checked? At the end of the transaction, by the command commit transaction?

Is it possible to switch on/off the referential integrity check while a database is running? If yes, are there any side effects beside that the integrity is not propre controlles anymore?

Thanks for your help in advance!

DominikWhat about this:

drop table test1
drop table test2
go
create table test2(id int primary key)
create table test1(id int, rid int)
ALTER TABLE test1 WITH NOCHECK ADD CONSTRAINT
FK1 FOREIGN KEY(rid) REFERENCES dbo.test2(id)
go
insert test2 values(1)
insert test1 values(1,1)
go
ALTER TABLE dbo.test1 NOCHECK CONSTRAINT FK1
go
insert test1 values(1,11) -- works

Tuesday, March 20, 2012

referencing fields in the code window

Hi, how do I reference a report field in a custom function which is written
in the code window (Report Properties/code tab)? i.e.
Function Something
If Fields!FIELD1_Company.Value = Nothing Then
Return ""
End If
End Function
This example will not work but it's similar to my needs
Thanks
NPSend the field value as a parameter to your function. i.e. re-write the
function as:
Function SomeFunction(byVal MyFieldValue as datatype) as datatype
if MyFieldValue is nothing
...
return ...
End Function
In your report expression, just call the function:
=Code.SomeFunction(Fields!MyField.Value)
Charles Kangai, MCT, MCDBA
"slk55guy" wrote:
> Hi, how do I reference a report field in a custom function which is written
> in the code window (Report Properties/code tab)? i.e.
> Function Something
> If Fields!FIELD1_Company.Value = Nothing Then
> Return ""
> End If
> End Function
> This example will not work but it's similar to my needs
> Thanks
> NP
>|||Thanks Charles, by the way how are you? I was on one of your DTS courses a
couple of years ago in the city. Small world eh?
I think this will work but there is another post (converting crystal code) I
put up here and basically I'm trying to get the same functionality as I would
in a Crystal function.
Happy Christmas
NP
"Charles Kangai" wrote:
> Send the field value as a parameter to your function. i.e. re-write the
> function as:
> Function SomeFunction(byVal MyFieldValue as datatype) as datatype
> if MyFieldValue is nothing
> ...
> return ...
> End Function
> In your report expression, just call the function:
> =Code.SomeFunction(Fields!MyField.Value)
> Charles Kangai, MCT, MCDBA
>
> "slk55guy" wrote:
> > Hi, how do I reference a report field in a custom function which is written
> > in the code window (Report Properties/code tab)? i.e.
> >
> > Function Something
> > If Fields!FIELD1_Company.Value = Nothing Then
> > Return ""
> > End If
> > End Function
> >
> > This example will not work but it's similar to my needs
> >
> > Thanks
> >
> > NP
> >|||Hi,
It should work. I am using something similar myself.
I did a demonstration and some conversations for a customer earlier this
week. The developers are all Crystal users, and they were so impressed with
Reporting Services that they are going to migrate all their sites in UK,
Italy, USA, and Denmark to RS within the next few weeks.
Great to come across you again - we will be running a Reporting Services
course from the end of Feb. I am the author. Check with Learning Tree.
Merry Christmas!
Charles
"slk55guy" wrote:
> Thanks Charles, by the way how are you? I was on one of your DTS courses a
> couple of years ago in the city. Small world eh?
> I think this will work but there is another post (converting crystal code) I
> put up here and basically I'm trying to get the same functionality as I would
> in a Crystal function.
> Happy Christmas
> NP
> "Charles Kangai" wrote:
> > Send the field value as a parameter to your function. i.e. re-write the
> > function as:
> >
> > Function SomeFunction(byVal MyFieldValue as datatype) as datatype
> > if MyFieldValue is nothing
> > ...
> > return ...
> > End Function
> >
> > In your report expression, just call the function:
> > =Code.SomeFunction(Fields!MyField.Value)
> >
> > Charles Kangai, MCT, MCDBA
> >
> >
> > "slk55guy" wrote:
> >
> > > Hi, how do I reference a report field in a custom function which is written
> > > in the code window (Report Properties/code tab)? i.e.
> > >
> > > Function Something
> > > If Fields!FIELD1_Company.Value = Nothing Then
> > > Return ""
> > > End If
> > > End Function
> > >
> > > This example will not work but it's similar to my needs
> > >
> > > Thanks
> > >
> > > NP
> > >

referencing fields in code

I'd like the user to decide how to group the report. For this I have the
parameter KStar and a piece of custom code.
Under 'Edit group' I use the expression:
=Code.GetGroups(Parameters!KStar.Value )
In the code window I have a function that starts like this:
Public Shared Function GetGroups (Byref KStar As integer)
Select (KStar)
Case 1
Return(Fields!K1.Value)
Case 2
Return(Fields!K2.Value)
It gives me the error:
[BC30469] Reference to a non-shared member requires an object reference.
How do I solve this? I am obviously very new to Reporting Services and I
would appreciate any help.
Thanks!First try replacing Fields!KStar.Value by Report.Fields!KStar.Value, if that
does not work you will have to pass the field values in as a parameter
--
Wayne Snyder, MCDBA, SQL Server MVP
Mariner, Charlotte, NC
www.mariner-usa.com
(Please respond only to the newsgroups.)
I support the Professional Association of SQL Server (PASS) and it's
community of SQL Server professionals.
www.sqlpass.org
"maple" <maple@.discussions.microsoft.com> wrote in message
news:E87A2353-646F-4FA9-AA2D-367BCB91348D@.microsoft.com...
> I'd like the user to decide how to group the report. For this I have the
> parameter KStar and a piece of custom code.
> Under 'Edit group' I use the expression:
> =Code.GetGroups(Parameters!KStar.Value )
> In the code window I have a function that starts like this:
> Public Shared Function GetGroups (Byref KStar As integer)
> Select (KStar)
> Case 1
> Return(Fields!K1.Value)
> Case 2
> Return(Fields!K2.Value)
> It gives me the error:
> [BC30469] Reference to a non-shared member requires an object reference.
> How do I solve this? I am obviously very new to Reporting Services and I
> would appreciate any help.
> Thanks!
>

Monday, March 12, 2012

Referencing a CLR DLL in a Custom Task

Is there a way you can reference a prebuilt CLR function in a custom dataflow task?

The CLR and the custom dataflow task are one in the same. The reason that I'm designing the custom task is that I find that it's time consuming to make a call to the database to retrieve a function to work on something that's already in memory. Also, another reason is that if the code needs to be updated, it doesn't have to be done in 2 places allowing for less confusion.

I tried adding a reference to the CLR function in my SSIS dataflow task, but when I try running it in SSIS, I get the error saying it cannot use a SQL CLR defined task in the package which I believe is due to this reference in the CLR code:

[Microsoft.SqlServer.Server.SqlFunction]
public static string toCase(string text, string caseType)

Is there a way to circumvent the [...SqlFunction] line of code when the DLL is referenced by an SSIS dataflow task, or do I just have to deal with having 2 copies of the same code?

Thanks in advance!

Nevermind, I guess the only way to do it is to separate the function as a core class and then create a CLR wrapper and then an SSIS wrapper.

Reference to a non-shared member requires an object reference

Hi,
I tried to use a custom assembly, written in C#. I received the following
error:
"[BC30469] Reference to a non-shared member requires an object reference..."
Here's the detail info for the custom assembly:
*I have 2 C# files. I did not write the code. So my C# knowledge is
limited. I removed some of the code within the methods because it gets very
long. Here is the code:
--[IConvertor.cs]--
using System;
namespace sbu.convertor
{
public interface IConvertor
{
string convert(string label, string direction, string val);
string convertByUnit(string before, string after, string val, string
direction, string group, string format);
string convertByUnit2(string before, string after, string val, string
direction);
string getUnit(string usUnit, string saUnit, string direction, string
group);
string getUnit2(string usUnit, string saUnit, string direction);
}
}
--[Convertor.cs]--
using System;
using System.IO;
using System.Xml;
using System.Globalization;
namespace sbu.convertor
{
public class Convertor:IConvertor
{
private static Convertor instance;
public static IConvertor getInstance()
{
if (instance==null)
{
instance = new Convertor();
}
return instance;
}
private XmlDocument doc;
private string docSource = null;
private NumberFormatInfo format;
public Convertor()
{
if(File.Exists("C:\\Inetpub\\wwwroot\\rocks\\itapps\\sbu\\sbu_convertor\\conversion.xml"))
{
//pdu dev box
docSource = "C:\\Inetpub\\wwwroot\\rocks\\itapps\\sbu\\sbu_convertor\\conversion.xml";
}
if(File.Exists("C:\\Inetpub\\wwwroot\\rocks\\itapps\\sbu\\sbu_convertor\\conversion.xml"))
{
//webdevtest
docSource = "C:\\Inetpub\\wwwroot\\rocks\\itapps\\sbu\\sbu_convertor\\conversion.xml";
}
doc = new XmlDocument();
doc.Load(docSource);
format = new NumberFormatInfo();
format.NumberDecimalDigits = 3;
format.NumberGroupSizes = new int[] {3};
format.NumberGroupSeparator = ",";
format.NumberDecimalSeparator = ".";
}
public string convert(string label, string direction, string val)
{
return (double.Parse(val)*getRatio(label,direction)).ToString();
//return "0000000000";
}
private double getRatio(string label, string direction)
{
XmlNode node = doc.SelectSingleNode("RICETEC/LABEL/CONVERSION[@.ID='"+label+"']/"+direction);
string valStr = node.InnerText;
return double.Parse(valStr);
}
public string convertByUnit(string usUnit, string saUnit, string val,
string direction, string group, string format)
{
////
}
public string convertByUnit2(string before, string after, string val,
string direction)
{
////
}
public string getUnit(string usUnit, string saUnit, string direction,
string group)
{
///
}
public string getUnit2(string usUnit, string saUnit, string direction)
{
///
}
public string convertTemp(string val, string direction)
{
///
}
}
}
* Here is how I complied it:
csc /t:library /out:bin/sbu_convertor.dll *.cs
Thanks in advance. JLI found a solution. I simply added the class and instance names in the
Reference tab. That fixed it.
"JL" wrote:
> Hi,
> I tried to use a custom assembly, written in C#. I received the following
> error:
> "[BC30469] Reference to a non-shared member requires an object reference..."
>
> Here's the detail info for the custom assembly:
> *I have 2 C# files. I did not write the code. So my C# knowledge is
> limited. I removed some of the code within the methods because it gets very
> long. Here is the code:
> --[IConvertor.cs]--
> using System;
> namespace sbu.convertor
> {
> public interface IConvertor
> {
> string convert(string label, string direction, string val);
> string convertByUnit(string before, string after, string val, string
> direction, string group, string format);
> string convertByUnit2(string before, string after, string val, string
> direction);
> string getUnit(string usUnit, string saUnit, string direction, string
> group);
> string getUnit2(string usUnit, string saUnit, string direction);
> }
> }
>
> --[Convertor.cs]--
> using System;
> using System.IO;
> using System.Xml;
> using System.Globalization;
> namespace sbu.convertor
> {
> public class Convertor:IConvertor
> {
> private static Convertor instance;
> public static IConvertor getInstance()
> {
> if (instance==null)
> {
> instance = new Convertor();
> }
> return instance;
> }
> private XmlDocument doc;
> private string docSource = null;
> private NumberFormatInfo format;
> public Convertor()
> {
> if(File.Exists("C:\\Inetpub\\wwwroot\\rocks\\itapps\\sbu\\sbu_convertor\\conversion.xml"))
> {
> //pdu dev box
> docSource => "C:\\Inetpub\\wwwroot\\rocks\\itapps\\sbu\\sbu_convertor\\conversion.xml";
> }
> if(File.Exists("C:\\Inetpub\\wwwroot\\rocks\\itapps\\sbu\\sbu_convertor\\conversion.xml"))
> {
> //webdevtest
> docSource => "C:\\Inetpub\\wwwroot\\rocks\\itapps\\sbu\\sbu_convertor\\conversion.xml";
> }
> doc = new XmlDocument();
> doc.Load(docSource);
> format = new NumberFormatInfo();
> format.NumberDecimalDigits = 3;
> format.NumberGroupSizes = new int[] {3};
> format.NumberGroupSeparator = ",";
> format.NumberDecimalSeparator = ".";
> }
> public string convert(string label, string direction, string val)
> {
> return (double.Parse(val)*getRatio(label,direction)).ToString();
> //return "0000000000";
> }
> private double getRatio(string label, string direction)
> {
> XmlNode node => doc.SelectSingleNode("RICETEC/LABEL/CONVERSION[@.ID='"+label+"']/"+direction);
> string valStr = node.InnerText;
> return double.Parse(valStr);
> }
> public string convertByUnit(string usUnit, string saUnit, string val,
> string direction, string group, string format)
> {
> ////
> }
> public string convertByUnit2(string before, string after, string val,
> string direction)
> {
> ////
> }
> public string getUnit(string usUnit, string saUnit, string direction,
> string group)
> {
>
> ///
> }
> public string getUnit2(string usUnit, string saUnit, string direction)
> {
> ///
> }
> public string convertTemp(string val, string direction)
> {
> ///
> }
> }
> }
>
> * Here is how I complied it:
> csc /t:library /out:bin/sbu_convertor.dll *.cs
>
> Thanks in advance. JL

Reference report items within a custom assembly?

How do I reference report items (such as textboxes, datasets, tables, etc...) from within a custom assembly?

Thanks!

You have pass them as paremeters (reference or by value) to the custom assembly method.

Shyam