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

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

How to read XML using LINQ in VB.NET

Posted By:      Posted Date: August 21, 2010    Points: 0   Category :ASP.Net

Can someone please tell me (sample code) how to read this XML into a SQL DB?  Should I use LINQ to XML?  Does anyone have any sample code?  I am working in VB.NET


<?xml version="1.0" encoding="utf-8"?>

<ReadOrderResponseType xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xmlns:xsd="http://www.w3.org/2001/XMLSchema">

<Status xmlns="urn:mysol:apis">Success</Status>

<TimeStamp xmlns="urn:mysol:apis">2010-07-25T15:26:49.1150235Z</TimeStamp>

<StoreUrl xmlns="urn:mysol:apis">http://xyz.COM</StoreUrl>

<PageResponse xmlns="urn:mysol:apis">




View Complete Post

More Related Resource Links

Read value of ID using LINQ

Hi,How i can ready the id value from below xml file in asp.net using VB language?<?xml version="1.0" encoding="iso-8859-1"?> <main> <callshop> <Inquiry id="inq_fun">Inquiry</Inquiry> <List id="acc_fun">Account List</List> </callshops> <Action> <Block id="blo_fun">Block</Block> <Delete id="del_fun">Delete</Delete> </Action> <Others> <Inbox id="in_fun"> Inbox</inbox> <Sent id="sn_fun">Sent</Sent> </Others> </main>Thank You

Read CSV using Linq - System.IndexOutOfRangeException


I'm trying to get data from a CSV file and add it directly into a database using Linq.

I'm using the following code:

Dim dataImport = From line As String In File.ReadLines("c:\temp\test.csv").Skip(1)
		Let CR = line.Split(Chr(124)) _
		Select New [property] With { _
		.ADDRESS_1 = CR(0), _
		.ADDRESS_2 = CR(1), _
		.ADDRESS_3 = CR(2) _

The code works if I remove all the but the first property e.g.

Dim dataImport = From line As String In File.ReadLines("c:\temp\test.csv").Skip(1)
		Let CR = line.Split(Chr(124)) _
		Select New [property] With { _
		.ADDRESS_1 = CR(0) _

But then I get the old "System.IndexOutOfRangeException: Index was outside the bounds of the array." exception when adding more columns. 

I really want to get this working...

Any ideas?

Read XML stored proecure result with linq 2 sql


I've build a query, but i like to read all values from it ,right now i only get the result of the metatags.
I also want to read the results of the tblContent.

I  access the stored procedure with linq to sql:

        public static XDocument GetPageXML(int MenuID, int LanguageID)
            DbaseDataContext db = new DbaseDataContext(SelectDB());

            string raw = db.spXMLGetPage(MenuID, LanguageID).First().XML_F52E2B61_18A1_11d1_B105_00805F49916B.ToString();
            XDocument xml = XDocument.Parse(raw);

            return xml;


Stored procedure:


alter PROCEDURE [dbo].[spXMLGetPage]
 @MenuID int,
 @LanguageID int

print 'metatags';
 1 as Tag,    
 null as Parent,    
 MetaTags.ID AS [MetaTags!1!ID!element],
 MetaTags.description AS [MetaTags!1!de

Playing with Linq grouping: GroupByMany?

One of its features is grouping. Many people understand grouping like it is defined in Sql. Linq is implementing grouping quite the same way. Let's discover this syntax and how to make consecutive groups easier.

LINQ : Implementing IN and NOT IN

I got tried of typing

var result = from s in source
where items.Contains(s)
select s;and so I implemented the IN and NOT IN methods as extension methods:

101 LINQ Samples Tutorials

101 LINQ Example with sample code snippets....This sample prints each element of an input integer array whose value is less than 5. The sample uses a query expression to create a new sequence of integers and then iterates over each element in the sequence, printing its value

Linq: how to share parameters between lambda expressions ?

When using Linq to objects, you will quickly feel the need to pass some parameters from a method to another but it's not so easy because each Linq method is not calling the following one. In a Linq sequence, each method is using the result computed by the previous one. So, local contexts are not visible from one method to another.
The compiler is using two technical different ways to let parameters go out of a method.

Linq to Sql CompiledQuery container

Ok now let's go. Here is just a little trick but with some interesting patterns that could be useful in some other contexts not connected to Linq to Sql.

When using Linq expressions, like with Linq to Sql, translating the expression into something else (sql for example) is taking time and resources. Sometimes it's negligible, sometimes not...

LINQ to SQL Paging using GridView in C# and ASP.NET 3.5

This tutorial will show you how we can extend the LINQ to SQL Class and create methods that will allow us to page data from a SQL database. C# version.

What is Lambda Expressions In LINQ

A lambda expression is an anonymous function that can contain expressions and statements, and can be used to create delegates or expression tree types.

All lambda expressions use the lambda operator =>, which is read as "goes to". The left side of the lambda operator specifies the input parameters (if any) and the right side holds the expression or statement block. The lambda expression x => x * x is read "x goes to x times x." This expression can be assigned to a delegate type as follows:

How to create 3 tier application using LINQ

As you know that in 3 tier architecture there are three layers

User interface layer. (Is our Form in Windows application and .aspx page in Web application)
Data Access layer. (Which provides interface between Business logic layer and Database)
Business Logic layer.(Which stores your application logic)

Building a LINQ Provider

Throughout this article, we will build a simple IQueryable provider similar to the LINQ to SQL provider demonstrating what is needed to build a custom provider that is capable of executing LINQ queries and performing create, update and delete operations.

LINQ to SQL Performance Considerations

As developers we have a wide array of tools at our disposal. One of the most time consuming, but most beneficial tasks we must undertake is to determine which of those tools to use for a given situation.

Serial Port Communication Read and Write using C#.net

In this simple article you will learn that how you can Open and read COM port data using System.IO.Ports Namespace.
Simply just create New Project of windows application in C#.

Import ServiceProcess APIs
using System.IO.Ports

Imports System.IO.Ports

Write Parsing functions which parse port data according to attached device

Passing Linq Statement between master and content page


I usually work with windows forms, and am just starting to work with ASP.Net, so appologies if this is a dumb question!

I have a master page which has a search button on it. The results of this are built up using a Linq statement and if there are any results, I want to display the results in a contents page.

On the masterpage, I have the following code:

Private _res

    Public Overridable ReadOnly Property SearchRes()
            Return _res
        End Get
    End Property

 Private Sub DoSearch()
   'some code to get a linq result

    If res.Any Then
            _res = res
            Server.Transfer("SearchResults.aspx", True)
            'no results
            LabelNoRes.Visible = True
        End If
 End Sub

On the SearchResults.aspx page I have this code.

Dim m As pxSite = CType(Page.Master, MasterPage)
        If m.SearchRes IsNot Nothing Then
            Label1.Text = "Results found = " & m.SearchRes.Count
        End If

m.searchRes is always nothing. 

What am I doing wrong here?


Scripts not read when in head tag


I just upgraded to VS2010 if that matters.  I'm learning JQuery and noticed that scripts don't work if they're in the head tag.  Also, I need the script tag with type="text/javascript" in the head (with nothing else) in order for the JQuery scripts in the body to work.

Very bizzare, any suggestions?

With a separate script tag in the <body> with my JQuery script, this works

<head runat="server">
<script type="text/javascript" src="http://ajax.googleapis.com/ajax/libs/jquery/1.4.2/jquery.min.js" />
<script type="text/javascript">

This doesn't:

<head runat="server">
<script type="text/javascript" src="http://ajax.googleapis.com/ajax/libs/jquery/1.4.2/jquery.min.js" />

Linq - add data to database then email user the details


Hi all

I'm not sure how to structure the code for this but what I want to do is be able to add data to a database, and once this has completed successfully, then email the user to say the details have been added successfully to the database.

I need to:

1. Check that the relevant data has been added into the database then

2. Email the details of the relevant data when completed. 


Thanks in advance for your help,




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