.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

Loop a Table Like for each syntax

Posted By:      Posted Date: October 01, 2010    Points: 0   Category :ASP.Net

Using SQL server 2008.

I have a table whose rows contains parameters for processing 

I need to process in order

I apply two methods but both  fails and give exceptions......

An error occurred while executing batch. Error message is: Exception of type 'System.OutOfMemoryException' was thrown.

For a short Description

1st Method : Take temporary table and add column row and loop by row number

insert into #tempMyTable(USERID,UTIME,CHECKTYPE,Row)

select USERID,<

View Complete Post

More Related Resource Links

Loop through table records using variable


I know it’s possible to loop through table records using a variable and a For Each Loop Task. But is there a way to use the values in the variable and use them in a File System Task? When I tried, the File System Task complains that the variable is not a string. Any thoughts?


Objective – I need to loop though column values in a table which has the paths to the files that I’ll need to move using File System Task.   The table only has one column which stores the paths to the files to be moved.


Thanks in advance.

How to bind data from linq to html table without a single line of loop.




This is the above code i have worked using querysing and displaying the listitem with in  a simple html table. Here I am using foreach statement to bind items. How to bind the data to a simple html table using SharePoint linq without  a single line of loop.

using System;
using System.ComponentModel;
using System.Web;
using System.Web.UI;
using System.Web.UI.WebControls;
using System.Web.UI.WebControls.WebParts;
using Microsoft.SharePoint;
using Microsoft.SharePoint.WebControls;
using System.Linq;
using Microsoft.SharePoint.Linq;

namespace QuerystringProgramWithoutLoop.QuerystringProgramWithoutLoop
    public class QuerystringProgramWithoutLoop : WebPart
        string strTitle=string.Empty;
        string strStatus=string.Empty;
        protected override void Render(HtmlTextWriter writer)

foreach loop - insert record in table



i createa a data flow task and read the records from a table to recordset.

now i inserted a foreach loop container which needs to go thru each record loaded in recordset from dataflow task. i made enumerator to foreach as ado enumerator and set the ado object source variable to recordset variable name from data flow task. also radiobox , rows in the first table is marked.

i also mapped the variable in foreach loop.


my question is how i can use these variable to insert variable values in antoher table?


mark it as answer if it answered your question :)

Loop is failing when writing to table


My site extracts data from a MS SQL db and then connects to a mySql db which it writes the data to. My site is working properly when connecting to a db in cPanel at a remote website.

However, I have a mysql db also hosted on my site, and I'm connecting to it ok, but the loop is failing. There are 2 tables, one stores the category, and the other stores link data.

For each category

write to the category table

  for each link in this category

 write to the link table



The tables are being created, and the very first category is written to the table, but then nothing gets written to the link table.

How can I make this generate an error message? My webhost doesn't know what to do about it and they just want to see an error message.

I tried this once already, and neither of my lines worked:

HttpContext.Current.Response.Write(lnkid & " " & url)

Why doesn't that get written into the source of the page on each iterance of the loop? How do I see the data that isn't being written?

Public Shared Function TransferDatabase(ByVal websiteID As Integer) As Boolean
        Dim con As New MySqlConnection(getMySqlConnectionString(websiteID))

        Catch ex As Exception

Create index in create table syntax



What is the syntax for create table with some index?

(Create table ...

   INDEX X () ... what should I write here?)

Also, where is a good document for all sql-server syntax.

on http://msdn.microsoft.com/en-us/library/aa258255(SQL.80).aspx I didn't find any. clue for the question above.

Thanks :)

loop through table with regex


I need to loop through tables on a web page and combine table rows with 1 <td> tag. I'm replace </td></tr><tr><td> with a <br /> tag. The problem is when there's more than one <td> tag in the same <tr>.

            <td>line 1</td>
            <td>line 2</td>
            <td>line 3a</td>
            <td>line 3b</td>
            <td>line 4</td>

Table variables do not re-initialize in a loop


Hi all,

I came across a peculiar problem while working with table variables. Here is a simple code to demonstrate it:


declare @c tinyint

set @c = 1

while @c <= 2
    declare @t table (srn int identity(1,1), name varchar(5))
    insert into @t(name) select 'A'
    insert into @t(name) select 'B'

    select * from @t
    set @c = @c + 1

The table variable does not get re-initialized and continues with the same identity seed for the next iteration.

I was wondering if anybody can throw some light on this behaviour of table variables where they do not get re-initialized with a declare statement. I worked around this problem by creating a temporary table and dropping at the end of each iteration nevertheless I was wondering if any tweak can help with using the table variable.



Export Visio Database Table Names to Excel

If you use the Enterprise Architect edition of Microsoft Visio for data modeling regularly, then there is a good chance that at some point you've wanted to export just the table names into Excel. You might want to do this to map logical ERD entities to physical data model tables, track project status by entity, or track overlap between database versions.

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:

Insert value using Table Value Functions

a real gem in Sql Server 2008. mostly people still using Stored procedure may be they shifted to SQL Server but they are not using TVF right now.

Using jQuery to Filter Table Rows

The project is using the .net GridView control, so I had limited control over the output HTML code. Still, I think this code can work for most tables. One thing to notice: you should use the class "filterable" on your table or on one of its parents for the code to work.
First, we need a text box:

RadioButton Groups, Table Rows And NamingContainers in asp.net

The RadioButtonList. Very handy for inviting users to select just one item from a list although because of the screen real estate it takes up, used less and less in favour of the DropDownList. In plain HTML, the browser knows to enforce the unique selected value amongst a list of radio buttons because they all have the same value for their name attributes.

RadioButton Groups, Table Rows And NamingContainers

(In which AJAX-enhanced CheckBoxes become more useful than RadioButtons but inheritance saves the day, and a simple RadioButton-derived control establishes the purpose of a control's naming container)

The RadioButtonList. Very handy for inviting users to select just one item from a list although because of the screen real estate it takes up, used less and less in favour of the DropDownList. In plain HTML, the browser knows to enforce the unique selected value amongst a list of radio buttons because they all have the same value for their name attributes.

Building a 3-Tier App with Silverlight 3, .NET RIA Services, and Azure Table Storage

Silverlight 3, .NET RIA Services, and Windows Azure Services Platform makes a 3-tier Cloud application easier to build: Silverlight 3 as presentation tier, .NET RIA services as the business logic and data access tier, and Windows Azure Table as the data storage tier. The sample application in this article demonstrates the architecture with a simple Survey application with all these technologies working together from Windows Azure.

Temporary tables in SQL Server vs. table variables

When writing T-SQL code, you often need a table in which to store data temporarily when it comes time to execute that code. You have four table options: normal tables, local temporary tables, global temporary tables and table variables. I'll discuss the differences between using temporary tables in SQL Server versus table variables.

Import XML File to SQL Table

Here is a brief example of importing an XML file into SQL Server table. This is accomplished by using the BULK option of OPENROWSET to load the file, and then utilizing the XQuery capabilities of SQL Server to parse the XML to normalized table format. This example requires SQL server 2005 or SQL Server 2008.

First, the following XML is saved to XML file C:\Products.xml.

Adding the table row below a particular row.


What is the best method in jQuery to add an additional row to a table as the row below a particular row?

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