Custom Conflict Resolver Example Code In C#

Dec 5, 2006

Hi!



I'm trying to create a custom conflict resolver for SQL Server 2000 in
C# but i can't seem to find any source code examples of a *.dll where i
can actually see what needs to be done.



Any help is welcome.



Thanks

View 3 Replies


ADVERTISEMENT

Custom Conflict Resolver

Jan 26, 2006

Hi there,

I have created a custom conflict resolver for an article that is using Merge replication. I can register my custom resolver OK, I can change my merge article to use my new custom resolver, but when a conflict occures the replication monitor shows the following errors:

Error messages:


No signature was present in the subject.
(Source: MSSQL_REPL, Error number: MSSQL_REPL-2146762496)
Get help: http://help/MSSQL_REPL-2146762496

The Custom Resolver Component for article 'BRANCH' does not have a valid digital signature. (Source: MSSQL_REPL, Error number: MSSQL_REPL-2147198713)
Get help: http://help/MSSQL_REPL-2147198713

At first I thought it was because my assembly wasn't signed, so I signed it. I still get the same error.

I have various debug statements in the assembly and I can see that Initialize and HandleChangeStates gets called ok, but no other overrides.

Can anyone help me please?

Thanks

Graham

View 3 Replies View Related

Need Help On COM-based Custom Conflict Resolver

Dec 21, 2006

Hi everyone,

I am working on a COM-based custom conflict resolver (vb.net) for a merge replication problem that I am having. This is what I am trying to accomplish. 1. Have a Last_Upd_Dt column. 2. When there is a conflict between publisher and subscriber on a column, the winner is the most recent date in Last_Upd_Dt and want the value for that column from that source. 3. If there is no conflict on a column and the column was updated by either the publisher or subscriber, I want to keep the change made by the publisher or the subscriber. (i.e publisher made change in col #1, subscriber made change in col #2, no conflict, the resulting row will now have the col #1 value from publisher, col # 2 will have value from subscriber. Essentially merging the changes.)

Does anyone have any examples of a COM-based Conflict Resolver that implements ICustomResolver for SQL Server 2005? Can this be done using the Business Logic Handler (examples?) ?

TIA

View 4 Replies View Related

Creating And Configuring Custom Conflict Resolver.

Aug 12, 2005

Hi

View 1 Replies View Related

Stored Procedure Based Custom Conflict Resolver Truncates Data

May 17, 2007

I created a stored procedure based custom conflict resolver in SQL 2005, I return the winning result set and also save that result set to a test table to compare the values. The values saved to the test table are correct but some of the values saved as the conflict winter are truncated.

Example a char(3) filed is updated at the subscriber as €˜111€™ and updated at the publisher as €˜222€™, in my custom conflict resolver if I use the value from the subscriber the conflict resolver updates the field as €™11 €˜, if I use the publisher value the conflict resolver updates the field as €™22 €˜. Now the same records is saved to the test table correctly as either €˜111€™ or €˜222€™ depending on the logic I used. So the result set has the correct values, its after the custom conflict resolver is called where the values is somehow truncated. Has anybody run into this before and what steps can I take to avoid this.

Thank you,
Pauly C

View 1 Replies View Related

Replication Conflict Resolver

Jan 18, 2007

Hi Everyone!
Here another post on replication.

When conflict occur, I want the user to be able to select witch row to keep and witch to delete.

I've look for system stored procedure, that could help me do the resolution but I've founded nothing.

So I've thought that I could do it by hand, with UPDATE/DELETE query
Take the row in the %TABLE_NAME%_Conflict table and copy it into the real table, than delete the row.

I this the good way of doing it?

Is there any other way?

Thanks !

View 5 Replies View Related

RMO + Interactive Conflict Resolver Setup

Nov 6, 2006

Hello,

I'm trying to setup the Interactive Conflict Resolver in my C# app via RMO. (using SQL Server 2005)

The only article I can find on MSDN or anywhere is involing T-SQL. Can someone please shed some light on this for me specificaly on the subscriber side.

Thank you! Chris

View 2 Replies View Related

Default Conflict Resolver In Sql 2000

Sep 20, 2005

Hi, I'm replicating a database between two instances of Sql 2000 using Merge Replication. I have no custom resolvers at present but I'm seeing something unexpected.

View 5 Replies View Related

Example Of Stored Proc Conflict Resolver?

Oct 2, 2006



Hi all,

I need to write a custom conflict resolver for an application using merge replication. It's relatively simple logic - compare the two rows from the publisher and the subscriber and the winner is based on the value of one particular column.

Reading BOL gives me the input parameter list for the sp, and specifies that the output should be exactly the winning row. What is doesn't give is any example of how to do this, in particular how to access the two rows in conflict so that they can be compared.

I can do this by dynamically building SELECT statements, one connecting to the table locally on the publisher and another connecting to the subscriber using the form SERVER.DATABASE.OWNER.TABLE, but this requires me to explicitly have the subscriber as a linked server to do this. An example of my revolting code is appended to this post.

Is this what I have to do, or is there some table I can access on the publisher that has the conflicting rows in so I can compare them without going back to the subscriber?

Thanks for your help



Richard

---- code sample --

ALTER PROCEDURE [dbo].[prRep_ResolveInventoryConflicts]

@tableowner sysname, @tablename sysname, @rowguid uniqueidentifier,
@subscriber sysname, @subscriber_db sysname,
@log_conflict int OUTPUT, @conflict_message nvarchar(512) OUTPUT,
@destination_owner sysname

AS

BEGIN

DECLARE @qrySubscriber varchar(255)
DECLARE @qryPublisher varchar(255)
DECLARE @Publisher sysname
DECLARE @RecentCheck datetime

-- Temp table with same form as tbl_Inventory

CREATE TABLE #ConflictingRows (
[Machine] [sysname]NOT NULL,
[LocationID] [int] NOT NULL,
[PartGUID] [uniqueidentifier] NOT NULL,
[Qty] [int] NOT NULL ,
[LastUpdatedDtm] [datetime] NOT NULL,
[LastUpdatedUser] [varchar](50) NOT NULL ,
[rowguid] [uniqueidentifier] NOT NULL

)

-- Build the T-SQL To run against publisher and subscriber

SET @Publisher = @@Servername
SET @qryPublisher =
'INSERT INTO #ConflictingRows
SELECT '+@Publisher+' as Machine, * FROM '+@tableowner+'.'+@tablename+
'WHERE rowguid = '+CAST(@rowguid as varchar(40)) +';'

SET @qrySubscriber =
'INSERT INTO #ConflictingRows
SELECT '+@subscriber+ ' AS Machine, * FROM '+@subscriber+'.'+@subscriber_db+'.'+@tableowner+'.'+@tablename+
'WHERE rowguid = ' + CAST(@rowguid as varchar(40)) +';'

-- execute the stored procedures

EXECUTE @qryPublisher;
EXECUTE @qrySubscriber;

-- Compare the two rows and return the winning row, ie the one that was last updated by a human checking the inventory

SELECT @RecentCheck = MAX(LastUpdatedDtm) FROM #ConflictingRows

SELECT TOP 1 * FROM #ConflictingRows where LastUpdatedDtm=@RecentCheck;

-- Cleanup and exit

DROP TABLE #ConflictingRows

END

----

View 11 Replies View Related

Creating A Conflict Viewer/resolver

May 22, 2006

Hello,

I see that MS has a conflict viewer that can be accessed by managment studio, however I would like to create one with some customized options. Is there a sample of code somewhere to start this? I could really find anything in BOL. Thanks in advance.

John

View 1 Replies View Related

Merge Replication Does Not Work With Non-default Conflict Resolver

Aug 4, 2015

I have been evaluating merge replication, 'push' subscription on SQL Server 2014. If the default resolver is used (I refer to @article_resolver parameter of sp_addmergearticle), all seems to work as expected. However if I use "Microsoft SQL Server Subscriber Always Wins Conflict Resolver" (or any other MS standard resolver for that matter), if the Subscriber is on a different machine, the merge agent invariably gives the following error: "The process could not initialize <resolver_name>. Verify that the component is registered correctly."

This does not happen if the Subscriber is on the same machine as the Publisher and Distributor.

The problem seemed to exist in SQL Server 2008 according to some posts but it has been apparently fixed since then. I've tried the following:

- @partition_options = 0, as was suggested somewhere.

- Copied ssrpub.dll (the resolver dll) to the Subscriber machine (should not really matter as this is 'push' subscription?)

- Registered ssrpub.dll with regsvr32 on the Publisher/Distributor machine.

I've also run sp_enumcustomresolvers on the Publisher machine, and it happily showed all standard resolver, including the "Microsoft SQL Server Subscriber Always Wins Conflict Resolver".

Another thought is, I'm using SQL Server Express as the Subscriber (on the remote machine). Perhaps it does not support custom resolvers? (I'm using the full SQL Server in the 'local subscriber' variant, which does work OK as I mentioned before).

Note also that if I create a new publication via SSMS, the Resolver tab of the Article Properties dialog is empty, i.e. it does not list any resolver. The same tab contains the full list of resolvers though, if opened for an existing publication.

View 2 Replies View Related

False Merge Conflicts - Impact On Conflict Resolver

Oct 12, 2007

I am using SQL 2005 build 9.0.2227

I have a custom conflict resolver - which fires on update conflicts (using row level tracking)

I have had a couple of occasions when the resolver has failed with the following error:

"The schema of the custom Dataset object implemented in the business logic handler does not match the schema of the source Dataset object. Verify that the custom Dataset object has been correctly defined"

In both cases I found that the row for which a conflict was being handled was not a conflict at all. One was a straightforward non conflicting update at the publisher and the other was a similar update at the subscriber.

I got round the problem by temporarily using a fix version of the conflict resolver dll that either set the custom Dataset to the publisher dataset or the subscriber dataset - depending on where the update had occurred.

When the first error (publisher update) occurred - the resolver code was basing the custom dataset on the publisher dataset - which was presumably empty - so I changed the code to base the custom dataset on the subscriber dataset. The second error therefore occurred when the custom dataset was based on the subscriber dataset - which again was presumably empty

Note that the tables involved in each occasion were different and neither table is filtered.

Is there a known bug in this area?

I am considering trying to change the resolver code to identify false conflicts in order to workround the problem - but this would be difficult to test as I can't reproduce the problem

aero1

View 2 Replies View Related

Error While Changing Custom Resolver

Sep 26, 2007

Hi all,

here is the context of our problem:
- Publisher : version SQL Server 2005 SP2, table in SQL Server 2000 (80) compatibility level, publication in SQL Server 2000 compatibility level
- Distributor : SQL Server 2005 SP2
- Subscriber : SQL Server 2000 SP4 + hotfixes (version 8.00.2187)

There is only one article in our publication (a simple table with a GUID and a nvarchar(50) columns), and we have left the default resolver.

1 - The first synchronization of the subscription is successfully completed, and it is the same for the different updates/inserts/deletes or conflicts.

2 - Then we change the Resolver of our article by our own COM-Based Custom Resolver (developped in C# 2.0). This resolver only change the default behaviour: the subscriber always win (this is for a test, in the future we will have a complex business logic). All the synchronizations works fine and do what we want in the conflicts.

3 - We rollback the resolver to the default one... and here is the problem!

The synchonizations stop to work correctly. For all of them we've got the same error:
quote:Replprov.dll , 2007/09/25 14:26:07.591, 4000, 16890, S1, ERROR: ErrNo = 0x80045017, ErrSrc = <null>, ErrType = 8, ErrStr = The schema script '
declare @cmd nvarchar(1000)
set @cmd='exec sys.sp_MSchangearticleresolver @article_resolver=@ar, @resolver_clsid=@rc, @artid=@ai, @resolver_info=@ri'
exec dbo.sp_executesql @cmd, N'@ar> nvarchar(255),@rc nvarchar(40),@ai uniqueidentifie..." mailto:N?@ar">N'@armailto:N'@ar">N'@ar</A< A>> nvarchar(255),@rc nvarchar(40),@ai uniqueidentifie...

It is no more possible to synchronize this subscription... Any remark will be helpfull cause we did not find anything on the net concerning this error.

Thanks a lot!

View 1 Replies View Related

Custom Resolver For Merge Replication

Sep 7, 2006

Hi there!




I'm trying to create a custom resolver for merge replication exactly like in the MS example.


It seems to work, but only ONE time. If I change, insert or delete a
record in a table the second time, the subscriber monitor comes with
the following errors:




Error messages:

Attempted to read or write protected memory. This is often an
indication that other memory is corrupt. (Source: MSSQL_REPL, Error
number: MSSQL_REPL-2147199411)



The Merge Agent encountered an error when executing code in the
'UpdateHandler' method implemented in the business logic handler
'D:Program FilesMicrosoft SQL Server90COMMyResolver.dll'. Ensure
that the overridden 'UpdateHandler' method has been properly
implemented in the business logic handler. (Source: MSSQL_REPL,
Error number: MSSQL_REPL-2147199411)



This last error is of course dependant on my action (update, delete, insert).

My code is -exactly- like the example (I just stripped out the log message).



Does anyone know why I am "trying to read or write protected memory" ?



The thing is that I'm trying to create an application that detects if a
table changes. Is this the right way to do this anyway or are there
better solutions?



Any help is appreciated! Thanks!

View 13 Replies View Related

Debugging A Custom Resolver In VS2005

Jan 22, 2007

Hi,

I have created a custom resolver in VB .net (VS2005). The resolver works ( Both Publisher and Subscriber are SQL 2005 ), but I need to be able to debug the code within the resolver. How do I do this? I have tried a number of things without success.

Any suggestions would be appreciated.

Cheers

Neil

View 3 Replies View Related

Error While Changing Custom Resolver Between 2005 Publisher And 2000 Subscriber

Sep 25, 2007

Hi all,

here is the context of our problem:

- Publisher :

version SQL Server 2005 SP2
table in SQL Server 2000 (80) compatibility level
publication in SQL Server 2000 compatibility level
- Distributor : SQL Server 2005 SP2
- Subscriber : SQL Server 2000 SP4 + hotfixes (version 8.00.2187)

There is only one article in our publication (a simple table with a GUID and a nvarchar(50) columns), and we have left the default resolver.

1 - The first synchronization of the subscription is successfully completed, and it is the same for the different updates/inserts/deletes or conflicts.

2 - Then we change the Resolver of our article by our own COM-Based Custom Resolver (developped in C# 2.0). This resolver only change the default behaviour: the subscriber always win (this is for a test, in the future we will have a complex business logic). All the synchronizations works fine and do what we want in the conflicts.

3 - We rollback the resolver to the default one... and here is the problem!
The synchonizations stop to work correctly. For all of them we've got the same error:



Code SnippetReplprov.dll , 2007/09/25 14:26:07.591, 4000, 16890, S1, ERROR: ErrNo = 0x80045017, ErrSrc = <null>, ErrType = 8, ErrStr = The schema script '
declare @cmd nvarchar(1000)
set @cmd='exec sys.sp_MSchangearticleresolver @article_resolver=@ar, @resolver_clsid=@rc, @artid=@ai, @resolver_info=@ri'
exec dbo.sp_executesql @cmd, N'@ar> nvarchar(255),@rc nvarchar(40),@ai uniqueidentifie..." mailto:N?@ar">N'@armailto:N'@ar">N'@ar</A< A>> nvarchar(255),@rc nvarchar(40),@ai uniqueidentifie...




It is no more possible to synchronize this subscription... Any remark will be helpfull cause we did not find anything on the net concerning this error.

Thanks a lot!

View 3 Replies View Related

Custom Conflict Resolution Problem

Oct 22, 2006

Hi all,

I
am doing a work were i have to syncronize data between a Publiser
(PC, SQL SERVER 2005), and a subscriber (Pocket PC, SQL CE MOBILE). I
studied lots of articles and i managed to put the syncronization to
work, the problem is in conflict resolution!

The subscriber can΄t insert or delet, only update!!



For exmple: I have a table that contais the quantity of a product X,
for example 100 units, this goes to Pocket, but later arrive move 100
units that are increased in the PC, so we get 200 in the PC, (but 100
in Pocket), no problem if i syncronize now (Pocket will have 200 too),
but if remove in Pocket for example 50 units, i've changed the same
column in both Publisher and Subscriber database, if i syncronize now,
i'll have a conflict, the final result should be 150 of product X in
both databases (100 + 100 - 50), but the Publisher wins the conflict
and the final result is 200!



I never worked with stored procedures and in microsoft theres and article called How to: Implement a Stored Procedure-Based Custom Conflict Resolver for a Merge Article (Replication Transact-SQL Programming), but they dont explain it very well and i dont know how to do my own stored procedure and implement it to the merge article.



in my own stored procedure i'll have to do some calculations to get the
result i want, maybe using some table for the additions and
subtractions. (Does the com based Addition resolver do this for me???)



Maybe you have experienced some problem like this, and could help me!

How should i do the stored procedure?

Oh, i tried to use de addiction resolver and the average resolver
of com based but nothing happed, dont know why, i read some stuff and
i think the addition could solve my problem, but it doesn΄t work, i read above what you said and installed service
pack 1 for sql 2005, but i instaled and nothing
happened!
When i change to the resolver that the subscriver wins, it works, why addition dont work?

Thanx

View 3 Replies View Related

Merge Replication - Examples For Custom Conflict Resolvers?

Oct 30, 2006

I have gone through BOL and various online resources including this one and I can't find any examples on how to use custom conflict resolvers to generate a result row which is a combination of the rows to be merged.

BOL says it can be done, but suitable examples are missing. I have found various posts requesting examples from up to a year ago, but can see no replies with relevant information

In particular I would like to see examples of

1) A stored procedure based custom conflict resolver

2) A business logic handler written in VB .Net

Here's hoping

aero1

View 16 Replies View Related

Custom Code (Embedded Code) Question

Oct 16, 2007



Hi all,

Could someone tell me if custom code function can capture the event caused by a user? For example, onclick event on the rendered report?

Also, can custom code function alter the parameters of the report, or refresh the report?

Thanks.

View 2 Replies View Related

Using Custom Code

May 17, 2007

I am trying to use custom code on a report which is:



Public Function Percentage(decValueOne As Double, decValueTwo As Double) As Object

If (decValueOne = 0 Or decValueTwo = 0) Then
Percentage = 0
Else
Percentage = (decValueOne - decValueTwo)
End If

End Function



In my textbox I have:

=Code.Percentage(SUM(Fields!PreviousYTDExpenseAmount.Value, "Template_OutputData_Sales"), SUM(Fields!PreviousYTDExpenseAmount.Value, "Template_OutputData_CGS"))



When I run the report in design mode, I get the "#Error" on that report field.



Any help with why this is happening would be greatly appreciated!

View 2 Replies View Related

Custom Code....

Mar 21, 2007

Hey guys I have a problem I am trying to solve using custom code but I am open to other solutions.

Situation: I have multiple reports that the user can see. Example (Move In Corp. report, Move In Region report,Move In Division report, Mid Year Corp. report, Mid Year Region report,Mid Year Division report etc.) I have a stored procedure that returns all the information needed based upon the UserID being passed from the report to the stored procedure.

Goal: When the user logs in I want to be able to foward the user to a specific report based upon their userid (global in RS). I currently have three textboxes(Move In, Mid Year, Year End) with navigation enabled to jump to another report. The report to which the user is passed to is determined by an expression which is something like this for the Move In text box =IIF(Fields!orgtypeid.Value = 1,"Move In Corp","Move In Region"). The orgtypeid.value is returned by the stored procedure. I want to be able to forward the user a specific Move In report (Move In Corp, Move In Region, etc) without having the user select the textbox.



Any suggestions are greatly appreciated.

View 3 Replies View Related

Custom Code

Oct 24, 2007



Hello, this is probably a pretty easy one. I have made a report, and added custom code in the code tab on the report properties. But when I type code.whatever in a text box expression my function does not show. Does anyone know what I am doing wrong?

Thanks

View 3 Replies View Related

What Custom Code Can Access

Jun 8, 2007

I am trying to find ways around the limitation of not being able to resize columns based on the text input. I am dynamically setting what values a column is getting from my query. I am wondering if I can access the table (and thus, the columns) from within the custom code.

For example:

Public Function Whynot() As Integer
Report.table1.TableColumn1.Width = ....
table1.TableColumn.Width = ....
Return 0
End Function

Neither of these seem to work, anyone else have any ideas?

Thanks

View 2 Replies View Related

Is It Possible To Do A Redirect In The Custom Code?

Jun 11, 2007

Is it possible to do a redirect to an arbitrary page in by using custom code?



eg.



Public sub myRedirect()

response.redirect(http://www.microsoft.com)

End sub



/Alex

View 1 Replies View Related

Custom Code Question

Feb 21, 2008

I developed a ConnectionString assembly in custom code a while back. Now it won't work. I've changed boxes since. My question is do I have to have SQL Server and Reporting Services on my development machine to run Custom Code assemblies?

I put my dll in the PublicAssemblies folder. I see that I need to put my dll in C:Program FilesMicrosoft SQL Server80ToolsReport Designer but I don't have that folder.

When I try and set the ConnectionString to "=ReportingLibrary.ReportingLibraryFunctions.ConnectionString(User!UserID)", I get "Unrecognized Identifier." I checked the reference and it was still there from when the project was working before.





Code Snippet
using System;
using System.Security.Permissions;
using System.Configuration;
namespace ReportingLibrary
{

public class ReportingLibraryFunctions
{

public static string ConnectionString(string userName)
{

System.Data.SqlClient.SqlClientPermission oPerm = new System.Data.SqlClient.SqlClientPermission(PermissionState.Unrestricted);
oPerm.Assert();
string catalog;
string query;
string connectstring;
string datasrc = String.Format("Data Source={0};", ConfigurationManager.AppSettings["DataSource"]);
string userpwd = String.Format("User ID={0};Password={1};", ConfigurationManager.AppSettings["DBUsr"], ConfigurationManager.AppSettings["DBPwd"]);
query = "SELECT TOP 1 MyAcctKey FROM dbo.MyUserAcct WHERE UserName=@username;";
connectstring = String.Format("{0}Initial Catalog=MyMaster;", datasrc);
System.Data.SqlClient.SqlConnection connection = new System.Data.SqlClient.SqlConnection(String.Format("{0}{1}", datasrc, userpwd));
connection.Open();
System.Data.SqlClient.SqlCommand command = new System.Data.SqlClient.SqlCommand(query, connection);
command.Parameters.Add("@username", System.Data.SqlDbType.VarChar);
command.Parameters["@username"].Value = userName;
catalog = String.Format("MyDb_{0};", command.ExecuteScalar());
connectstring = String.Format("{0}Initial Catalog={1}", datasrc, catalog);
connection.Close();
return connectstring;
}
}
}

View 9 Replies View Related

Writing A Custom Code Example

Oct 19, 2007


I have been stuck in a problem for a while now. I am trying to count the number of groups. I tried soo many things and nothing worked . Now I want to try to write a function that does the counting for me.

Can somebody write me an example of a cutom code that can be called from expression.
So my custome code should be something like that

Public int CountFun(int counter)
{
Return counter= counter +1;

}

Also how do I call this method from my expression?
i am going to call it from a field inside the groups, so each time the group is implemented i add one to the counter.

thanks

View 4 Replies View Related

Nested Ifs In Custom Code

Sep 19, 2007

Is it not possible to have nested ifs in a custom code function? I keep getting an error message when I try it.

View 1 Replies View Related

Custom Code For A Parameter

Oct 3, 2006

I'm using a GAC-installed assembly as part of a Reporting Services
(2005) report. The code does not need any permissions beyond execution.
All it does it take today's date and calculate last week's start and
end date. It's all just datetime manipulations. All methods are static.

In
the VS2005 report designer, I can do everything fine. The code runs as
expected and defaults the parameters to the right date.

When I
upload the rdl to the Report Server, I get the message "Error during
processing of €˜Start€™ report parameter.
(rsReportParameterProcessingError) ". If I override the "Start"
parameter, it doesn't give me that error anymore. Start should be the
Sunday of the previous week.

I have deployed the signed assembly to the GAC on the report server as well as the bin folder for reporting services. Because it doesn't need anything beyond execution, I shouldn't have to modify any config files, right? I have already restarted IIS & the Reporting Services service.

What am I missing?

View 10 Replies View Related

Grouping And Custom Code

Jun 25, 2007

Hello everyone,



I've got an issue where I want to sum the group values and not the details, the reason is because I am hiding duplicate records. Here's how my Layout is setup.




TH

GH1 (hidden)

GH2 (hidden)

Det (hidden)

GF2 =Code.AddValue(Fields!Quantity.Value * Fieds!Cost.Value)

GF1 =Code.ShowAndResetSubTotal()

TF =Code.GrandTotal



I have the following in my Code window.




Dim Public SubTotal as Decimal

Dim Public GrandTotal as Decimal

Function ShowAndResetSubTotal() as Decimal

ShowAndResetSubTotal = SubTotal

SubTotal = 0

End Function

Function AddValue(newValue as decimal) as Decimal

SubTotal += newValue

GrandTotal += newValue

AddValue = newValue

End Function



This gives me incorrect results and I can't figure out why. Here's how it shows on my report:
















Part Number
Quantity

Cost
Regular Subtotal Method
Using Custom Code

Part 1
4,000

1.49
$5,947.20



Customer 1



$11,894.40
$0.00

Part 2
10

1.01
$10.07



Customer 2



$50.34
$5,947.20

Part 3
1

0.44
$0.44


Part 4
6,050

0.25
$1,530.41


Part 5
0

1.25
$0.00


Part 6
0

1.23
$0.00



Customer 3



$42,851.86
$10.07

Part 7
16,250

0.24
$3,922.59



Customer 4



$19,612.94
$1,530.85

Part 8
17,250

0.38
$6,544.82


Part 9
27,225

0.20
$5,380.20



Customer 5



$66,891.69
$3,922.59










Grand Total



$141,301.23
$0.00



The issues brought up from the duplicates is shown in the "Regular Subtotal Method" column (there are 2 detail records for Customer 1-Part 1, which is why it is doubled). I can't use a distinct on the SQL query because there are other fields (not shown) on the report that are different.



As you can see, the GF1 (Customer #) shows the subtotal from the previous group, and the Table Footer (Grand Total) shows 0. Why is this?



Jarret

View 2 Replies View Related

Bug With InScope() And Some Custom Code

May 30, 2006

Hi guys,

i was developing some custom code to do a running total in a matrix, and i have noticed some odd behaviour with the InScope function. I am doing year on year reporting, so i have two row groups on my matrix: the first is on month (matrix2_Calendar_Month), the second on year (matrix2_Calendar_Year).

I needed to total the number of days covered by the months i was reporting on, so i wrote some very standard code to do this, along with an expression in that column of the matrix:

=IIf(
 InScope("matrix2_Calendar_Year"),
 CStr( Round( Sum(Fields!Sales.Value / (24 * Code.AddDays( CStr(Fields!Calendar_Month.Value),  CInt(Fields!Calendar_Year.Value))), 2)) ,
 Code.getBounds()
)

Code.AddDays() calculates and returns the number of days in the month of that year on that row. Code.getBounds simply returns the lower and upper bounds of the array, plus its contents (so i can inspect them). This is what is returned in the report:

 













Month / Year

Sales

Capacity

% Capacity

Avg $/h



February

2006

3842

7706

49.86%

2.86



2007

0

0

0.00%

0



March

2006

4949

8692

56.94%

3.33



2007

0

0

0.00%

0



April

2006

5160

8154

63.28%

3.58



2007

0

0

0.00%

0



May

2006

3309

8348

39.64%

2.22



2007

0

0

0.00%

0



Total

17259

32900

52.46%

0-8*28,28,31,31,30,30,31,31,28

 

If you look at the output in the total row, you will see that Code.AddDays() has been called one extra time at the end,  with Feb 2006 as its parameters, thus adding an extra 28 days to the running total. Why is Code.AddDays called on the total row, when i should be out of the scope of both the row groups? (Note: this happens for whichever row group i use in the InScope check in the expression).

Here is the custom code used for all this:

Dim numDays()

Public Function AddDays(ByVal month As String, ByVal year As Integer) As Integer
    Dim thisMonth As String
   
    Dim upper As Integer
    upper = 0
    On Error Resume Next
    upper = UBound(numDays) + 1
    ReDim Preserve numDays(upper)
       
    thisMonth = CStr(year) & "-" & month & "-01"
    numDays(upper) = DateDiff("d", CDate(thisMonth), DateAdd("m", 1, CDate(thisMonth)))
    AddDays = numDays(upper)
End Function

Public Function TotalDays() As Integer
    Dim lower As Integer
    Dim upper As Integer
   
    lower = 0
    upper = 0
    On Error Resume Next
    lower = LBound(numDays)
    upper = UBound(numDays)
   
    TotalDays = 0
    Dim ii As Integer
    For ii = lower To upper  
        TotalDays = TotalDays + CInt(numDays(ii))
    Next
End Function

public function getBounds() as string
 getBounds = Cstr(LBound(numDays)) & "-" & CStr(UBound(numDays)) & "*" & Join(numDays, ",")
end function

 

sluggy

 

 

View 5 Replies View Related

Custom Code Spaces Being Cut Off

May 6, 2008

I have a custom C# assembly that my report is calling with embedded code that is called from fields in a reporting services table. The value comes back fine, but I need some of the values to be indented, so I have tried all of the following and every time the spaces are cut off. Spaces work when not using embedded code.

I tried the following in the table cell
=Space(3)+Code.<<String Function Name>>
and I tried
=" "+Code.<<String Function Name>>

Then I tried the code in the assembly and in the embedded code with the same result. No matter where I put the spaces they get cut off. Any ideas? I tried characters other than spaces and they came back fine.

Thanks,
Adam

View 5 Replies View Related

How Can I Throw A Custom Error Code?

Jun 26, 2006

I'm trying to run a DTS package, and cant find an easy direct way to run it.  It seems like the easiest solution would be to throw a custom error- then the server notices the error and runs a  custom job, and the custom job runs the DTS.  This is a roundabout way, but seems like it would be the simplest solution.Anyways, how do I throw the error in my code?  Do I just write a throw 3829 statement?  Also maybe this is a very bad way to do this- any suggestions?

View 2 Replies View Related

Custom Code...For The Sake Of Argument

Oct 3, 2006

Is it possible to write custom code that achieves the same thing as an aggregate function?

ex: Calculating the sum of a group? (with out using the sum( field!one.value) function)

if I had a group that grouped on name.


Name Number
header Fields!FirstName.Value ************
details Fields!Number.Value
footer

Can i write a custom code function (or functions) that will get the sume of the numbers in that group.

Thanks in advance.

View 7 Replies View Related







Copyrights 2005-15 www.BigResource.com, All rights reserved