.NET Tutorials, Forums, Interview Questions And Answers
Welcome :Guest
Sign In
Win Surprise Gifts!!!

Top 5 Contributors of the Month
Gaurav Pal
Post New Web Links

Endless update loop after return of customDataSet in UpdateHandler

Posted By:      Posted Date: August 31, 2010    Points: 0   Category :Sql Server
I have created a custom conflict handler for merge replication that responds to Inserts and Updates from both the Publisher and the Subscriber.  This is a prototype so the tables involved are limited. Unfortuntely, I get into an endless loop of updates back and forth. I respond to the Inserts and Updates because the SiteIndex of sites in the tblSites table are different on the two replication databases but their SiteID is the same.  When transferring records from the tblGroups table, I need to look up the SiteIndex and translate it to the right value for the target (Publisher vs. Subscriber).  Here’s the code for the Update:   public override ActionOnDataChange UpdateHandler( SourceIdentifier updateSource, DataSet updatedDataSet, ref DataSet customDataSet, ref int historyLogLevel, ref string historyLogMessage ) { int siteIndex = (int)updatedDataSet.Tables[0].Rows[0]["SiteIndex"]; int translatedSiteIndex = 0; if ( updateSource == SourceIdentifier.SourceIsPublisher ) { translatedSiteIndex = TranslateSiteIndex( PublisherSites, SubscriberSites, siteIndex ); } else if ( updateSource == SourceIdentifier.SourceIsSubscriber ) { translatedSiteIndex = TranslateSiteIndex( SubscriberSites, PublisherSites, siteIndex ); } if ( translatedSiteIndex != 0 ) { customDataSet = updatedDataSet.Copy(); customData

View Complete Post

More Related Resource Links

Fileupload with database parameters that need to return nothing on update

Hi All, Got a problem with regards to the file upload control on database updates. The problem is in my CMS, when a user tries to update content for a page it will add null to the fields containing the image path. What I need is for the system to check if the uploader has no image and if hasn't it has to do nothing. It can't add empty strings or null values as this will remove the original image path. Although they still need to be able to do image updates if the uploader has a file(this bits not a problem). Heres a snipet of code to demonstrate what I'm trying to achieve. protected void Button1_Click(object sender, EventArgs e) { if (Page.IsPostBack) { AddMenu menu = new AddMenu(); string APP_PATH = Server.MapPath(Common.GetAppSetting("_MENU_PATH")); if (FileUpload1.HasFile == false) { menu.Menu_Image1 = /////// Its this bit that has to do nothing //// Menu_Image1 calls a Parameter on the data layer /// Ie cmd.Parameters.AddwithValue("@image", _menu_image1) } else if (FileUpload1.HasFile) { if (FileUpload1.PostedFile != null && FileUpload1.PostedFile.ContentLength > 0) { Uploa

foreach loop and SqlDataAdapter to update WHERE UserId = UserId ?


I'm trying to figure out how to update multiple rows in my Directory table, when a user changes their Street Number or Street Name in their profile.  They can add multiple users to a directory and each user they add to the directory has this primary users UserId in it. So if the primary user changes their address, I want it to update the address for all the users they listed in the directory as well. I'm adding this to the On_Click in the Code Behind, so when they click to update their profile, it fires this function as well.

This code may be way off, but here's what I have right now:

                //Update directory user addresses for this account, if profile address has changed
                if ((currentStreetNumber != creatingStreetNumber) || (currentStreetName != creatingStreetName))
                    string myDirectoryConnection = WebConfigurationManager.ConnectionStrings["ConnectionString"].ConnectionString;
                    SqlDataAdapter cmd2 = new SqlDataAdapter("Update Directory SET [StreetNumber] = @StreetNumber, [StreetName = @StreetName] WHERE [UserId] = @UserId", myDirectoryConnection);
                    cmd2.UpdateCommand.Parameters.Add("@UserId", currentUserId.ToString());

SQL -loop\update and edit fileds

i have a database that have i want to loop through\update all rows and edit a field .
the filed will need to get a number that is depened on the previews 3 rows.
for example:
field1   field2    field3(the filed that i want to change)
1 1.5 -
2 1.75 -
3 3.25 -
4 2.65 -
lets asuum that in each row i want to write the sum of filed2 of the last 3 rows 
so in that example i will write in the 4th row 6.5 . 

plz help me :)

Attempt to update Modified field with UpdateListItems() return 0x81020030


I have written a custom migration tool using SharePoint web services to move SP content from 2003 to 2007. I'm using solution suggested by Steve Curran 



to set the tp_Modified field to Read_Only="False", update the Modified field with UpdateListItems(), then set back to Read_Only. This solution is working perfectly for SharePoint Versions and However moving to a new SharePoint instance, 12.0.06545, the call to UpdateListItems returns 0x81020030. ("Invalid file name"). This fails only for document libraries.





Microsoft's Collaborative Application Markup Language (CAML) Loop

discovered an interesting error recently while working with Microsoft's Collaborative Application Markup Language (CAML) that, surprisingly, had received no ink. Partly what surprises me about this is that the error may require you to rewrite large sections of your code if you haven't previously considered this SharePoint limitation. I'll start with some context, but first of all the error is:

ASP.Net Gridview Edit Update Cancel Commands

In ASP.Net 2.0, GridView Control also provides the functionality to edit and update the data retrieved from the database using CommandField template. You can cancel the action using Cancel Command of the CommandField. GridView consists of events that can be used to perform the actions like edit, update and cancel upon the Data items displayed in the ASP.Net GridView Data Control.

How to format and update GridView and DataGrid rows using JQuery

The behavior described in this question is as expected. When you set text of a cell in grid, it directly affects HTML that is going to be rendered. When you set text value of a cell, it means that you are setting innerText of the cell. The column that GridView creates for command fields (Edit, Delete and Select) are a (anchor) or button elements. So you can see what will happen if you set text value in that cell. It will wipe out those link or button controls and replace them with simple text string.

Update Vs SystemUpdate

Many of you might noticed that share point ListItem has Update() method as well as SystemUpdate().

What is the difference between these two methods and why MOSS has two different APIs for updating an ListItem

SqlCommand.ExecuteNonQuery() returns -1 when doing Insert / Update / Delete

Sometimes you end up with a return value of -1 when using the SqlClient.SqlCommand.ExecuteNonQuery method.

Why is that?

Well, the ExecuteNonQuery method is there for statements for changing data, ie. DELETE / UPDATE /INSERT, and the returned value are the number of rows affected by that statement.

When checking the documentation we can see that there are some conditions that return -1.

For UPDATE, INSERT, and DELETE statements, the return value is the number of rows affected by the command.

When a trigger exists on a table being inserted or updated, the return value includes the number of rows affected by both the insert or update operation and the number of

rows affected by the trigger or triggers. For all other types of statements, the return value is -1. If a rollback occurs, the return value is also -1.

>>>How to update multiple rows of gidview by one click



I want to add multiple rows of a gridview if the data for multiple fields are same.

Idea for this is that a user may search a record with some parameter e.g. Sector, plot.

For example 15 records being displayed in gridview.

There should be checkbox before every row and if user wants to update Plot and Flat No that is same for 10 rows out of 15 so he will check the rows and update.

For this a dialog box should appear asking for the parameter i.e. Plot and Flat or something else next time may be it will be City or country. Moreover, there is already an Edit button to update records, when user click it another page open for the record to be updated and whatever he wants to update, it updates.

Hope everone understand the scenario.

I don't want to disturb the already provided Edit functionality and want to provide same record to be updated.

Any idea in this regard would be appreciated.

ListView DataPager with SQL-Statements that already return only paged data.



As far as I understand the ListView-Control and the DataPager-Control, they work like this: The ListView gets its datarows from its data source, then the DataPager causes the ListView to display only a subset of those rows.

So what, when I want to use custom databinding for the ListView, that *already* gets the certain subset from SQL-Server (for better performance). Can I and how can I use the DataPager then?

Thanx, S.

Visual Studio closes itself by opening aspx-Page designer after Windows Update


Hey Guys,

I've a problem with my Visual Studio.

On the 13th of August 2010 i installed a Windows update on my vista sp2 pc. For this date my Visual Studio 2008 sp 1 always has closed itself by opening an aspx-page in designer view. There is no error message just closing the window. I restored a backup of my windows from the time before updating it and it helped, i could open aspx pages in the design view till the update has been installed again automatically after rebooting the pc. I can't disable windows updates, cause it's my pc at work and safety is very important. I hope you could help me out of this disaster.



Update net frame 3.5.


I use visual studio 2008 but It's only use net frame work 2.0, Can I update and use net frame work 3.5 for Visual Studio 2008 ? Please help me !


update/delete not working on server only


my aspx page works in VWD, and everything works on the server EXCEPT update and delete sql functions. any ideas?


Need Syntax To Make Results of LINQ Union Return Non-Generic Type



I have the below SQL which works just fine:

SELECT     Message, CreateDate, AccountId, AlertTypeId
FROM       dbo.Alerts
SELECT     TOP (100) PERCENT Status, CreateDate, AccountId,
                          (SELECT     10 AS Expr1) AS AlertTypeId
FROM         dbo.StatusUpdates
WHERE AccountId = PassedInParameter

I have been going about trying to convert the above into a LINQ method and am having problems with return types.
As the above SQL illustrates, I am querying two distinct LINQ tables - Alerts and StatusUpdates -
and then attempting to perform a Union on them. In order to do the union in LINQ, I have to have agreeing types. So, I
am using "var" to make the results of "alerts" and "updates" generic before the union.  

public IList GetStatusUpdatesAsAlertsByAccountId<T>(Int32 accountId)
            using (WorkbookDataContext dc = _conn.GetCont

XMLHTTP.ResponseText return unexecuted code?


I have a simple asp with the following code.  When I access this page directly (via browser) everything works fine:  the xml object shows up fine.  When I call this page via VBA (excel), the ResponseText method of the 

XMLHTTP object returns the below code unexecuted.  Anybody knows what's going on?  thanks.

<%@ Page Language="VB" AutoEventWireup="false" CodeFile="Default.aspx.vb" Inherits="_Default" %> <% Response.Buffer = True Response.ContentType = "text/xml" Dim oDataXML As Object 'Custom Data XML passed in by caller. On Error Resume Next 'Load the XML passed into the request. oDataXML = Server.CreateObject("Microsoft.XMLDOM") oDataXML.Load(Request) Dim sResult As String sResult = "<?xml version=""1.0""?>" sResult = sResult & "<OrderProcessed>" sResult = sResult & "<Status>test</Status>" sResult = sResult & "<OrderID>111</OrderID>" sResult = sResult & "</OrderProcessed>" Response.Write(sResult) Response.End() %>

Posting data to ASMX and return Object for jQuery


I am using fluent NHibernate with WebForms and I am trying to build a page where I allow a user to post a status update on their profile page and I a using a .asmx WebService to post the data to the database and then returnig a StatusUpdate instance to the page to be used by jQuery. I have a couple problems.

1) First off when I return a string from the WebService(i was testing) the textbox where the user enters their status doesnt empty the contents. And since the page doesnt refresh even if I manally clear out the textbox and put in something else, it still posts the previous status to the database again. How do I fix this?

2) Secondly, when I return the StatusUpdate Object from the Webservice I cant the results to display anything. Like I sad, Im using jQuery to make an AJX call to the WebService.

Here is my code:

User Profile Page:

Status: <asp:Label ID="status" runat="server"></asp:Label><span style="font-size:.7em;"><asp:Label ID="statustime" runat="server"></asp:Label></span><br />
<textarea id="statusBox" rows="3" cols="40"></textarea><br />
<input type="button" value="Update Status" onclick="SetStatus(); return false;
ASP.NetWindows Application  .NET Framework  C#  VB.Net  ADO.Net  
Sql Server  SharePoint  Silverlight  Others  All   

Hall of Fame    Twitter   Terms of Service    Privacy Policy    Contact Us    Archives   Tell A Friend