.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

Problem updating a boolean field

Posted By:      Posted Date: September 07, 2010    Points: 0   Category :ASP.Net
I have a button in a listview that updates a boolean field for the selected record. The button calls a method (ObsoleteOffice) in my BLL that sets the field (IsObsolete) to true...please see below for the code. However, the IsObsolete field never gets updated, nor does it throw an error.  In addition, the method works with string fields just fine, but nothing happens with the boolean field.  I would be grateful if anyone could shed some light on what I am doing wrong. Thanks.   //Method: ObsoleteOffice [System.ComponentModel.DataObjectMethodAttribute(System.ComponentModel.DataObjectMethodType.Update, true)] public bool ObsoleteOffice(int officeID, bool isObsolete) { offices.OfficesDataTable offices1 = Adapter.GetByOfficeID(officeID); if (offices1.Count == 0) // no matching record found, return false return false; offices.OfficesRow office = offices1[0]; // office.DateModified = DateTime.Now; office.IsObsolete = true; //Update the office record int rowsAffected = Adapter.Update(office); //Return true if exactly one row was updated, otherwise false return rowsAffected == 1; }  

View Complete Post

More Related Resource Links

Problem updating records with LINQ, Concurrency?

 My project includes a grid view with some updtable fields, some fields throw an error on update and some do not and it does not really make sense. WORK_STATION_ID does not cause an error, ROOM _ID cause an error, both are int? (I am using c#) and for update I use the code liste below.using (DataClassesDataContext db = new DataClassesDataContext()) { var product = (from p in db.ASSETs where p.ASSET_ID == ASSET_ID select p).Single(); product.WORK_STATION_ID=WORK_STATION_ID; product.ROOM_ID=ROOM_ID; db.SubmitChanges(); }    Row not found or changed. Description: An unhandled exception occurred during the execution of the current web request. Please review the stack trace for more information about the error and where it originated in the code. Exception Details: System.Data.Linq.ChangeConflictException: Row not found or changed. Source Error: Line 93: Line 94: Line 95: db.SubmitChanges(); Line 96: Line 97: Source File: C:\Projects\TEST_II\trunk\ObjectDataSourceLibrary\AssetController.cs Line: 95 Stack Trace: [ChangeConflictException: Row not found or changed.] System.Data.Linq.ChangeProcessor.SubmitChanges(ConflictMode failureMode) +963417 Syst

Updating a List item field value in a SPD Workflow is setting Date fields to null

Hello everybody,I faced a very weird behavior while creating a workflow in SPD against a Document Library.Here is the case:1- Create a document library in sharepoint site.2- Add a custom column of type DATE.3- Upload any document to the library4- Edit the item metadata and set the custom date field to any date you want.5- Now using sharepoint designer, create a very simple Workflow with only one action that updates the current item "Title" field to any value. (Note: In my case I set the workflow to start manually and not automatically)6- Save the workflow and then start it on the uploaded item.7- Now check the value of the date column after the workflow is finished.8- You will see that the Date field is Empty... (very weird)Notes:   1-This behavior will not appear on a standard list. it is only appearing in a Document library.  2- I am using WSS 3.0 SP2 + MOSS 2007 SP2. Also SharePoint designer 2007 SP2Did anyone face this situation and does it have a fix, or am I doing something wrong here... Please help.Regards,Maheed

Problem with CQWP "There is a problem with one or more of the field values below"

Hi, I'm trying out the content query webpart combined with content types. First I created a new site collection. In this site collection, these are the steps I did: - I enabled "SharePoint Server Publishing Infrastructure" feature at the site collection level - I enabled "SharePoint Server Publishing" feature at the site level - I created a new site column "Is Meat Eater", which is a yes/no field and added this to a new custom group called "Zoo" - I created a new content type called "Zoo Animal" that inherits from "Item" in category "List", and added this to a new custom group called "Zoo" - I added my site column "Is Meat Eater" to this content type (so now I have Title + Is Meat Eater) - I created a new custom list called "SharePoint Zoo" - I enabled content types on this list - I added "Zoo Animal" from the existing content types - I removed the default content type "Item" from the list (so now only 1 content type left, my own) - I added a few animals in the list - I added a content query web part on the homepage - As source I chose "Show items from all sites in this site collection" - As List Type I chose "custom list" - As Content Type Group I chose "Zoo" - As Content Type I chose "Zoo Animal" - I hit apply at

Problem when deployind ContentType: Error occurred in deployment step 'Activate Features': Field t

Im getting this error when i try to Deploy my ContenType: Error occurred in deployment step 'Activate Features': Field type GUID is not installed properly. Go to the list settings page to delete this field Does someone know how to fix this error? The ContentType is defined as: <     Elements xmlns="http://schemas.microsoft.com/sharepoint/"> <!--Site columns--> <Field Name="Test" DisplayName="Customer Subject ID" ID="{38A9E5BA-62FF-4F3B-90E3-F9961FEABE20}" Type="Text" Required="FALSE" /> <!--Parent ContentType: Item (0x01) --> <ContentType ID="0x01004317ec735b25468583d7470aa17c36ae" Name="NextContentTypes - NextCustomerContentType" Group="Next Content     Types"Description="NextCustomerContentType" Inherits="TRUE" Version="0"> <FieldRefs> <!-- References to field difinitions --> <FieldRef ID="{38A9E5BA-62FF-4F3B-90E3-F9961FEABE20}" Name="Test"></FieldRef> </FieldRefs> </ContentType> </     Elements>

Merge Replication and "Field size too large" problem

Hi,I have a single table database for tests configured on my server, I create another database using the same script that I use on my server on another server. I made a several inserts on the first database and I configure a merge replication between the two server and on the table article configure 2 integer columns to not be replicated and configure @pre_creation_cmd to none, because if I use another configuration on @pre_creation_cmd , when the snapshot applied it must recreated my table without the columns and I need then on another server. When I set @pre_creation_cmd  to none I need to create a rowguid column on the another server. My server is the Publisher and my another server is the publisher. I create the snapshot and when I sinconize the databases, the sinconization return that error:=================================================================================================The process could not bulk copy into table '"dbo"."CONSTS"'. (Source: MSSQL_REPL, Error number: MSSQL_REPL20037)Get help: http://help/MSSQL_REPL20037 Field size too large (Source: MSSQLServer, Error number: 0)Get help: http://help/0 To obtain an error file with details on the errors encountered when initializing the subscribing table, execute the bcp command that appears below.  Consult the BOL for more information on the bcp utility and its supported options. (Source:

Problem with updating assembly references in IIS server

I have a website which is in a Projects directory. The IIS server is set up to point to that website (i.e. any changes in the /Projects version are visible in the wwwroot version), so I can run the website locally on IIS server.One of the libararies that there is an assembly reference to in the website has been updated. If I run the /Projects website using the local ASP development server (localhost), I can open up the files in the library that have been changed and put a breakpoint in them, which will be triggered whenever that section of code is executed.However, when I run the IIS server version in webroot, if I put breakpoints in the same files, the breakpoint icons disappear, and it says that the symbols have not been loaded for the current page (presumably because the file is new, but the old code is being compiled in the assembly?). I have checked, and the library reference is set to auto update, and has the correct path to the dll in the project's .refresh file.I'm confused about this, since I thought the IIS server version was pointing to the same website as the one in /Projects, which works. If anybody has any advice on things that I can check or how I can fix this, I'd be grateful.

google map custom field type Rendering problem


Hi all,

I have rebuild the codeplex project of googlemapfield in visual studeio 2010 for sharepoint foundation 2010.It is able to show custom field when adding new column. I am unalbe to get  google map in display form.. I don't know where it went wrong. I am able to load a text pargaraph from control template file which is delcared in <div> as <p><cite>The Complete Manual of Typography</cite>, James Felici</p>. But not google map.

I have added safe control in web.config file and also enabled activex control scriptings in IE.

Here is my .ascx file code

<%@ Assembly Name="GoogleMapField64,Version=, Culture=neutral, PublicKeyToken=268a24657b14d504" %>
<%@ Assembly Name="Microsoft.Web.CommandUI, Version=, Culture=neutral, PublicKeyToken=71e9bce111e9429c" 

GridView updating problem


Hi all,

I'm trying to edit fields in my gridview, but for some reason it's not working. I've tested the sproc, and there's no apparent reason why it shouldn't work. When debugging the app and looking at e.Command.Parameters in both Updating and Updated (SqlDataSource), it only shows me the old values, which, to me, implies that this is the problem - it's not sending the updated values.

Anyone know how to fix this?

Cheers! :)

<asp:GridView ID="gvDisplayGroup" runat="server" AutoGenerateColumns="False" 
        <asp:BoundField DataField="RoleId" HeaderText="RoleId" 
            SortExpression="RoleId" ReadOnly="true" />
        <asp:BoundField DataField="RoleName" HeaderText="RoleName" 
            SortExpression="RoleName" />
        <asp:BoundField DataField="Description" HeaderText="Description" 
            SortExpression="Description" />
        <asp:BoundField DataField="role_level" HeaderText="role_level" 

Problem with assembly reference not updating


I have a solution A which references an assembly in solution B. I added the reference to the project in A by right clicking on the project > add reference, and finding the dll in the bin/Debug folder of the project in solution B in the Browse tab.
However, the reference to assembly B is not being updated in solution when I update the code in project B, even though I am making sure that I recompile the code in project B and then in project A. This means I am unable to debug A properly because the source code does not match the executable (I've checked and the location of the file the breakpoint is added to is correct).
I can go into the bin/Debug folder in project B, the date modified fields for the dll and .pdb files in

updating problem with ObjectDataSource control


hi all, i got confused about updating method with ObjectDataSource control. Those parameters just a nightmare for me. I tried use those parameters implicitly and explicitly, but coudln't get it working.

The task is to update the data from txtIllness and txtDiagnosis according to selected consultationID.

Any helps are greatly apperciated.

Thank you

Here is the code

public class ShowConsultation
    private readonly string constring;
    string name = HttpContext.Current.User.Identity.Name;
    public ShowConsultation()
        constring = WebConfigurationManager.ConnectionStrings["SurgeryConnectionString"].ConnectionString;
    public SqlDataReader GetConsultation()

        SqlConnection con = new SqlConnection(constring);
        SqlCommand cmd=new SqlCommand();
        cmd.CommandText = "SELECT Consultation.consultationID,Consultation.Illness,Consultation.Diagnosis,Consultation.Date,Patient.firstName,Patient.lastName,Patient.DOB,Patient.suburb,Patient.postCode FROM Consultation,Practitioner,Patient WHERE Practitioner.UserName=@UserName AND Practitioner.GPNo=Consultation.GPNo AND Patient.patientID=Consultation.patientID";
        return cmd.ExecuteReader(Com

Problem with calculated field in SSRS

i have the foll scenario:
col1 col2 col3 col4 
A   1  100 
   2  250 150 
   3  500 250 
   4  600 100 
   5  900 300 

For col4 i need to calculate the difference b/w (the value in current row in col3 i.e. 250) - (the value in the previous row in col 3 i.e.100). i need to do that for all rows of col4. I need help with the expression to do this in SSRS.

Workflow Updating Infopath Form Dropdown Field Keeps Breaking


I am using SharePoint Designer to create a workflow.  I am experienced in creating workflows this way, but it is my first go around with SP 2010 + SP Designer 2010. 

I am using InfoPath Services and have the form published as a content type to a form library.  I have a dropdown field that when the workflow runs, it will eventually change to another value in the list.  This HAD WORKED.  But twice now, I come into work the next day to find  the workflow will no longer set that field value.  Twice, I just rebuilt the workflow, only to have it break for no good reason, again.  

The workflow indicates that it runs and completes. For trouble shooting I created a step that said (in pseudo) 1. Write to the history log that the workflow started, 2. change dropdown field to value X.  3. Write to the history log that the value had been changed.

Well I get the history logs, but the value does not change.  Again, this was working twice, I know the function is possible.  But I am hoping that someone out there would know of any known issues that would cause this to break?  Other than a possible large amount of local variables added to the workflow, everything else is pretty straightforward.

North to the Future

Updating Person/Group Field when Current User Clicks Button


Hi all,

Im trying to either add the current user to a multi person/group field or remove them if they are already in the field when they click a button. My code works to decide which button to render on the page - it will show "Add" if the current user is not in the multi person/group field (titled Members) or it will display "Remove" if the current user already exists in the multi person/group field.

My problem is that when the user clicks the button, i want to take the value in the multi person/group field and use XSL string functions to either add/remove the current user to/from the string and push the updated string back into the multi person/group field - This is not working for me. I can reference the correct column with javascript, but it seems the value i get from the person/group column is not just a simple string, its got all sorts of HTML in there. I was hoping just to get a string like, "member1;member2;...). Ive tried changing the field to just display the account (rather than the name with presence), but it still pulls back a huge chunk of code that i cant work with.

Below is my code so far, just to give you an idea - anyone know what im doing wrong?


problem when programmatically updating value


Using vb.net/asp.net 2005 & Sql Server 2005.

I have a gridview that is using a sqlDataSource to update the value and when I trace through the following code, get the EmailID and query the database table to see if the change is made when inside this function the actual value of the emailAddress is changed:

    Protected Sub grdvMyGridView_RowCommand(ByVal sender As Object, ByVal e As System.Web.UI.WebControls.GridViewCommandEventArgs) Handles grdvMyGridView.RowCommand

            Dim intRow As Integer = CInt(e.CommandArgument)
            Dim row As GridViewRow = grdvMyGridView.Rows(intRow)

	If e.CommandName = "Update" Then

                Dim emlID As String = grdvMyGridView.DataKeys(row.RowIndex).Value.ToString
                Dim emlAddr As String = CType(row.Cells(0).Controls(0), TextBox).Text

                SqlDataSource1.UpdateParameters("EmailID").DefaultValue = CInt(emlID)
                SqlDataSource1.UpdateParameters("EmailAddress").DefaultValue = emlAddr

                grdvMyGridView.DataSourceID = "SqlDataSource1"

            End If

        Catch ex As Exception
		Throw ex
        End Try

    End Sub

I have a breakpoint at the rowCommand function shown abo

Lookup field which allows multiple choice - problem when query with CAML


I created one simple list and added one column - lookup - I've chosen some source list and field, then marked "Allow multiple choice". I created new item in that list, by adding more than one valie to that coulm.

The problem is, when I use CAML query, that column has such values:


and it's suppose to be like this:


do You have any idea, why it doesn't query first ID?

Update Existing Sharepoint List's field Problem



This is about sharepoint sequential workflow using visual studio.

I ve a prob to updating existing sharepoint list's field on the basis of other field(id or somthing else), using visual studio.

I m updating sharepoint list but its adding a new row below at last in the sharepoint list.

i m having a UserID(lots of user's ID) field in the sharepoint list, on the basis of this userID i ve to update a perticular field corresponding to UserID.

Please tel me wat type of code i ve to mension.


Thanks in advance !

Regards- Sharad

Problem with [ID] in TITLE Field.


On my TITLE column, I have set the default field as: "SPF-FW2010-&[ID]" ... however the error is that the [ID] is not being pulled from the existing [ID] field (that is the unique number that auto-increment). How can I go about solving this?

My desire output should be example:





... and so on.

Thanks in advance.

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