.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

Linq to XML Strange Problem

Posted By:      Posted Date: April 14, 2011    Points: 0   Category :ASP.Net


I have a complex XML file to be parsed. So, I decided to do that using Linq to XML. I have no doubts that I did the best choice, but I'm fighting against a stranger problem: I can read all descendents nodes inside an Element, except one.

See the XML example below and I will explain that better, so you will be able to help me:

<det nItem="1">
            <cEAN /> 
            <xProd>SOFTWARE </xProd> 
      <infAdProd>-ISENTO DE ICMS </infAdProd> 

1. Inside the XML file, there are a lot of <det nitem="n">
2. Problem: Using the ASP.NET code bellow I'm able to parse (read) everything above, except the <infAdProd> node.


Dim xmlFile As XDocument = XDocument.Load(LocalXMLPath)
Dim xmlFilePRO

View Complete Post

More Related Resource Links

Strange Photo upload problem


I'm working project it's live on shared hosting

we'er uploading photos to a file on the server everything works fine the photo is resized renamed and sent to the folder

the upload page returns the thumbnail and the full size photo it's there all the photos have to be approved by an admin

twice now after they have been approved they disapear I checked the folder they are not there could there be anywhere

on the server they could get hung up before they go into the folder I have it setup so when you delete the data base entry it deletes the photo from the folder othe than that you need to open the folder and delete the photo this has hapened twice now I tried to recreate it with no luck

thaks for your help in advance

Strange URL Routing Problem, participially working


I am setting up URL Routing on my existing project. I am not using mvc.

The routing only working like this: http://www.example.com/sdevil.m

not working with single word like this: http://www.example.com/sdevil

I am getting error message:The resource cannot be found.

Looks like when I using single word, application think that is folder?

How can i fix this? Thank you for any helps.

LINQ query with multiple joins, problem


I am using a LINQ query with multiple joins, the last join does not return any values even though values exist in the database. Below is my code.

when the query returns suiteNameTrg and SuiteTypeTrg are empty, all other values are returned correctly.

string suiteNameTrg = string.Empty;
            string suiteTypeTrg = string.Empty;
            using (DataClassesDataContext db = new DataClassesDataContext())
                    var productQuery = from assets in db.ASSETs
                    join relocatableUnits in db.RELOCATABLE_UNITs on assets.RUID equals relocatableUnits.RUID into assets_units
                    from relocatableUnits in assets_units.DefaultIfEmpty()
                   join build in db.BUILDINGs on assets.BUILDING_ID equals build.BUILDING_ID into assets_bins
                   from build in assets_bins.DefaultIfEmpty()
                   join test in db.TEST_SUITEs on assets.TEST_SUITE_ID equals test.TEST_SUITE_ID into test_bins
                   from test in test_bins.DefaultIfEmpty()
                    join testTrgt in db.TEST_SUITEs on assets.TARGET_TEST_SUITE_ID equals testTrgt.TEST_SUITE_ID into testTrgt_bins
                    from testTrgt in testTrgt_bins.DefaultIfEmpty()

                    select new

Wickedly Strange .Net WPF Performance Problem Dissapeers with Windows 7 Performance Monitor Open

Hello Everyone, I have been developing one large and complex WPF application for 13 months now, all is going well and especially tonight as I now have some sort of clue or hint to what I have been seing now for quite some time.  Here is the rundown. 1) Running on i5 processor with 4GB RAM and Windows 7 2) The application was developed all in .Net 4.0, WPF C#. 3) It is heavily GUI intensive and also uses Entity Framework Detached for Database Access. 4) Is multi-threaded / multi-tasking. I am a nutcase when it comes to testing.  Since my graphical application heavily depends upon performance and determinsm (please somebody don't start with the C++ vs .Net on here) and has been performing great FOR THE MOST PART.  Every once in a while, I see that the application runs into the weeds for 5 or 6 seconds and the interface is unresponsive.  I have this thing tuned finely too.  Well now toward the end of development I have finally had to face that bug so to speak.  I can force it by clicking spastically on my buttons causing an event storm and making the system update the GUI.  SO!  Great start, I can now cause the problem on a regular basis (for you youngsters that is actually a good thing)!  Alright, so I start with the easiest investigative tool, CNTRL - ALT - DEL into Windows 7 Performance Monitor.  As you can tell from

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

Strange Problem - SSIS Fails with "Syntax error, permission violation, or other nonspecific error".

Hello, I have a strange issue while I am deploying a package to one of the environment server. I have 2 XML Source, in the DataFlow, and one will extracted based on a value of variable that is passed from run time (package is executed from a Job) and other will be extracted all time. The next Step I have is a Execute SQL Task in ControlFlow wihich will execute after DataFlow. This has 2 input parameters and some SQL query that uses the param. Now this one fail on the target environment with below error: failed with the following error: "Syntax error, permission violation, or other nonspecific error". Possible failure reasons: Problems with the query, "ResultSet" property not set correctly, parameters not set correctly, or connection not established correctly. I got the error when I did a SSIS Text File Log. Note: If I run the package in BIDS with the same XML files it work. Also when I deploy the package to my Dev Server it works. When I compare the Dev DB with the target environment DB - Both are same. The Service Acount has permission - as I can see the DataFlow task completed. Another Point: The XML Load Data Flow that executes based on the Variable Value does not execute on target environment, even if the value is passed as "True" (It is Boolean Type) But this variable is NOT an input for the Execute SQL task that fails. I am not sure w

Strange for loop problem

Hi, I have this problem with moving a number of documents stored in a SharePoint Document Libray progamatically.The Document library is called "CR" which stores Change Management word documents.  Within this document library there may or may not be a folder which stores attachments (other documents, pictures etc) associated with the CR Document. When a button is pressed this code should see if the CR document has a corresponding folder, and then iterate through each file in that folder and move it to another archive folder.The code I have is as follows:SPList crlist = CR.Web.Lists["CR"]; for (int i = 0; i < crlist.Folders.Count; i++) { if (crlist.Folders[i].Folder.Name == "CR " + CR["CR Number"]) { for (int ii = 0; ii < crlist.Folders[i].Folder.Files.Count; ii++) { crlist.Folders[i].Folder.Files[ii].MoveTo(folderlist.RootFolder.ServerRelativeUrl + "/" + year.ToString() + "/" + WorkflowItem.Title + "/" + crlist.Folders[i].Folder.Files[ii].Name); } } }CR is list item (codument) which this code is working on at the time.crList is the sharepoint docu

Problem while retrieving data from a lookup column from sharepoint linq.

Hi I am working with sharepoint linq concept. When I am giving a query with lookup column It's working fine.  But when i am trying to retrieve the data from a look up column to spgridview. I was unable to get the output. Here is the above code which i have worked.   string strTitle = string.Empty; string strStatus=string.Empty; var context = new LinqSampleDataContext(SPContext.Current.Web.Url); EntityList<SharePoint2010ConceptsItem> Concept = context.GetList<SharePoint2010ConceptsItem>("SharePoint 2010 Concepts"); var query = from cs in Concept where cs.Status.Title.ToString()!="Completed" select new { cs.Title, cs.Id, //cs.Status }; sgvConcepts.DataSource =query; sgvConcepts.DataBind();   Any help me plz how to retrieve the data from a lockup column.bvnprasad

Problem with Retrieving data from lookup column using SharePoint 2010 Linq Concept

Hi I am working with sharepoint linq concept. When I am giving a query with lookup column It's working fine.  But when i am trying to retrieve the data from a look up column to spgridview. I was unable to get the output. Here is the above code which i have worked.   string strTitle = string.Empty; string strStatus=string.Empty; var context = new LinqSampleDataContext(SPContext.Current.Web.Url); EntityList<SharePoint2010ConceptsItem> Concept = context.GetList<SharePoint2010ConceptsItem>("SharePoint 2010 Concepts"); var query = from cs in Concept where cs.Status.Title.ToString()!="Completed" select new { cs.Title, cs.Id, //cs.Status }; sgvConcepts.DataSource =query; sgvConcepts.DataBind();   Any help me plz how to retrieve the data from a lockup column.bvnprasad

WCF very strange problem

Hi,My issue ie a little bit comlicated, and I hope I'll find someone who will be able to deal with my complicated problem...I'll tryto describe it:1. I have a few wcfs that I located inside a website for having them "on air" on iis and ready to be called.    I have a website contains service references to those wcfs.2. Our web server is behind a load balancer, so we give another local name to each web service / website for a case     of calling them from inside the server. We declare the names changes in the "hosts" file. What I did is:1. upload the website with the wcfs. I also gave it a start simple page for being sure it is on the air:http://qonlineservices.qgroup4u.com/ you can see that the simple test page is writing moshi.2. Making services references in my website: www.QEnglishCenter.com to the appropriate WCFs thatlocated in: http://qonlineservices.qgroup4u.com/. I could easily create the service references because the wcfs therewere recognized immediately.3. I changed the urls to the wcfs inside the web.bconfig and the other files in the service reference: svcinfo, wsdl, disco... to bethe local url that we gave them.4. I changed the url in the web.config to the local url.5. I didn't changed the binding of the endpoints to webhttp or something like this.I hope

Linq to SQL Web Service cannot be serialized problem

Hello All, Ok so I'm playing around with Web Services using Linq to SQl. I apparently have  a lot of learning to do. What I'm trying to do below is pull data from the Northwind db Employee Table. I don't need to see the whole table, I'm just trying to select individual(s) but I keep getting the following error  "System.Data.Linq.Binary cannot be serialized because it does not have a parameterless constructor" Code Below: Thanks in advance for any advice <WebMethod()> _ Public Function EmployeeInfo() As List(Of Employee) Dim db As New NorthwindDataContext() Dim output = From cust In db.Employees _ Select cust.EmployeeID, cust.FirstName, cust.LastName Return output End Function  

Linq to SQL - Association Property Name problem

Is it possible to specifiy a custom property name for a foreign key association in Linq to Sql? For example, if you have an "Order" class that has a "Customer" EntityRef, that's fine.  But what if instead of myOrder.Customer you wanted the property name to be myOrder.PreferredCustomer.sqlmetal and the designer are both always using the table name as the Property name.  So myOrder.Customer is the only option I have, other than hacking through the generated file.You can change the storage option of the association attribute, but that pertains to the underlying member, NOT the public property.Thanks.

LINQ: Problem in fetching data

Hi, i am developing something in LINQ, in this i am using some query for selecting data like this:var data = (from w in db2.TextSubCats where w.SubCatName.Trim()==reci_i.Recipe_cat.Trim() select w.SubCatName);but how could i fetch this data, i knows there is a solution by using foreach statement like this:foreach (var data_i in data){}my problem is this, if there no data returned by query then this foreach statment is just skipped.....so how could i get data returned by query in string so that i could perform my string manipulations... Thanks for your time.

Custom Webpart not working on "My Profile" page but works on all other pages. Linq Problem?

Hi, I created a publication site and in that site i created pages with specifique metadata (using a pagelayout with a custom content type)0. My webpart is getting data from those pages and displaying it. My webpart works on every page except on the "my profile" page(overview tab). I get the following error: Invalid Url: /TestSites/course I used the SPMETAL to create a class and i'm using this class to retrieve the data from the pages (with linq). The url i give to the entity is http://pcp/TestSites/course  this works fine on every site except on the my profile page. Can anybody help me? Here is the code i use to retrieve my data: EntitiesDataContext ctx = new EntitiesDataContext(courseSite); //Code below gets only the pages with a courses contentType. //EXCEPTION TRIGGERT ON THE FOLLOWING LINE IF IN PROFILE PAGE EntityList<Courses> course = ctx.GetList<Courses>("Pages"); //Writing the query to get the correct pages(with the course page layout only! var Query = from myCourse in course.ToList() where myCourse.CourseParticipants.Contains(myWeb.CurrentUser.LoginName) Select new{myTitle = myCourse.CourseTitle, myCompany = myCourse.Company, myPath = myCourse.Path, myName = myCourse.Name }; Thx.    

a problem with Linq to Entities



i have a query that get some data from database and i want to databind a drop down list control that have alredy an item in it

the code is:

Private Sub DatabindFamilyMembers()

        Dim db As New AghakhanianEntities()
        Dim members = From m In db.UserProfiles _
                     Where m.IsFamilyMember = True _
                     Select FullName = m.FirstName + m.MiddleName + m.LastName, m.ProfileID _
                     Order By FullName

        Dim i As Integer = 0
        Dim text As String
        Dim value As String
        Do While i <= members.Count()
            value = members(i).ProfileID
            text = CType(members(i).FullName, String)
            i = i + 1
            ddlParent.Items.Insert(i, New ListItem(text, value))


    End Sub

when i run it in line value=.... get some error like:

LINQ to Entities does not recognize the method 'VB$AnonymousType_2`2[System.String,System.Int32] ElementAtOrDefault[VB$AnonymousType_2`2](System.Linq.IQueryable`1[VB$AnonymousType_2`2[System.String,System.Int32]], Int32)' method, and this method cannot be translated into a store expression.

Strange clipping problem

I am trying to design a control that resembles a door and it's swing. 
I have a few transforms to alter the swing. 
I am having a problem when the transform flips the rectangles and arcsegment out of the bounds of the UserControl. 
Even when I have the ClipToBounds property set to false on the UserControl and the MainWindow I still have problems.
The MainWindow will clip the UserControl even though the transform shows the UserControl. Please help.
UserControl x:Class="Test.SingleLeaf"
       xmlns:Test="clr-namespace:Test" mc:Ignorable="d" 
       x:Name="_singleLeafDoor" ClipToBounds="False"

MOSS 2007 Strange Problem with edit forms, content types and document library columns


I'm having a strange problem and have not been able to track down any useful answers over google.

I inherited a SharePoint site that I am now making some changes to.

I am having problems with one document library.  We had custom edit forms on this document library, which I was finding a pain to maintain so I reset them back to the site definition.  This edit form now shows only those fields that are associated with the Document content type (the only content type - I've deleted the others) on the document library.  There are other columns on this document library that are NOT associated with the content type that I would like to show on the edit form but they are not available when I try to add them to the content type via Settings > Document Content Type > Add from existing site or list columns.  The select columns from drop down is set to List Columns.  The Additional Authors column is just not there.

I CAN see this field on the all items view for the document library, it is there and populated with data.

Setting the Allow Managed content types radio button to NO does not have any impact on which fields are visible on the form- I still see those same fields that have been associated with the Document content type.

Has anyone else seen this or does anyone have any thoughts?? 

They will be muc

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