.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

Repeated (loop) SQL Updates not executing

Posted By:      Posted Date: September 30, 2010    Points: 0   Category :ASP.Net

Hi all,

I have a stored procedure as followes

Create PROCEDURE [dbo].[spInventoryOverride]
		@Prefix		nvarchar(50),
		@Sufix		nvarchar(50),
		@Total		int

DECLARE @ProdID int 
SELECT @ProdID = dbo.ProductVariant.VariantID  FROM dbo.Product INNER JOIN dbo.ProductVariant ON dbo.Product.ProductID = dbo.ProductVariant.ProductID WHERE (dbo.ProductVariant.SKUSuffix = @Sufix) AND (dbo.Product.SKU = @Prefix)

UPDATE    dbo.ProductVariant
SET       Inventory = @Total
WHERE     (VariantID = @ProdID)


I then Have a loop to go though an array and get the prefix/suffix and the inventory total and send it to this SP to be updated.

The problem is only the first record (first time the loop goes arround) the record gets updated. The second time and so on I am sure the data is good (as it should find the record to be updated just fine) but it will not update that record. (am using SQL 2008, VS.NET 2008, Asp.net 2.0, VB.NET)

What am I doing wrong?

any Ideas?

Any help would be greatly appreciated :)

Thank you,


View Complete Post

More Related Resource Links

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:

Formview LinqData source not allowing updates


OK, I'm confused.  I've set up a formview with a Linqdata source to allow users to edit records.  When I run it, edit data and submit, it blows up and tells me "Linq datasource6  does not support the Select property when the Delete, Insert or Update operations are enabled."  I googled that warning and saw a couple of posts on this forum saying the problem is the slect statement has to be removed from the Linq data source for it to allow updates. 

But if I remove the select statement then how do I show the user specific info on pageload?   plus I thought the two way databind was an advantge of the datasource control.




for each loop



Need help in for each loop. i'm poor in for each loop. i wanna create a for each loop that can give me 2 value in each rows.

i create a for loop.. but is a mulitple rows. Anyone can help ?

here is my code.

Dim x As Integer, y As Double, x1 As Integer

        Dim d As Date, prevD As Date
        Dim d1 As TimeSpan

        temp_sec = ac.getTempTime(ddl_date.SelectedValue, ddl_id.SelectedValue)

        For I As Int32 = 0 To temp_sec.Tables(0).Rows.Count - 1
            If I Mod 1 = 0 Then
                ' To prevent list out of bounds
                If I + 1 < temp_sec.Tables(0).Rows.Count Then
                    d = temp_sec.Tables(0).Rows(I).Item(0)
                    prevD = temp_sec.Tables(0).Rows(I + 1).Item(0)
                    d1 = prevD - d
                    x = d1.TotalSeconds
                    x = x1 + x
                    y = temp_sec.Tables(0).Rows(I).Item(1)
                    list.Add(x, y)
                    x1 = x
                End If
            End If

On page loading or executing all CSS flags are ignored and website is plain without formatting


 My problem is whenever i execute my app the first page that loads is the login page pointed to by my web.config file forms authentication, this page is meant to show CSS formatting for the info i am displaying but it is not. Any help with this problem would be great. A cut and paste of my problem is shown below as you can see there is no CSS.

jsfdnjldfngjfg here it is

Account Login
User Id:
Forgot Password?

I have inserted all the link as in:




SQL and Outlook: Enable Database Access and Updates Through Exchange and Any E-mail Client


Using Microsoft technologies, you can insert, edit, query, and delete database entries using any e-mail client such as Hotmail, Outlook, Yahoo, or even WAP phone. While e-mail is certainly a powerful and widely used tool, it is usually not integrated with an application for performing any tasks other than sending reminders. The application scenario described here, an e-mail-based SQL update program, uses a simple data model; however, this solution will apply to any data model that you are working with. It will also eliminate the need for complex n-tier Internet applications and serves as a low maintenance solution for providing data access.

Alok Mehta and Daniel Williams

MSDN Magazine January 2002

How to stop the repeated database queries for roles


Hello, friends,

We have a web application using VS 2008, c#. We try to filter siteMap nodes based on security roles. We have our customized the mether GetRolesForUser() in RoleProvider class to determine a user's role. In this method, roles will be returned by querying an SQL Server database.

However, we found that each time a page was loaded/refershed, this  GetRolesForUser() was called, and the database would be queried. This is too MUCH and expensive.

We thought the roles should be queried only once when a user logs in. After that, role info should be stored somewhere for this user, rather than query DB all the time.

Any ideas, reference paper, snipet,...,?

Thanks a lot!

Item cannot be found.(rsItemNotFound) when executing a report from a sharepoint Website

I have managed to integrate Report server with Sharepoint .
I created a report with it's data connection with microsoft Visual Studio 2005 , tested it , than deployed it to the specified document libraries in sharepoint.
Everything works fine till now.But when i try to execute the report from the document library in sharepoint the Message :
  • The item 'Reports/Report1.rdl' cannot be found. (rsItemNotFound) '. Even though the report1.rdl is inside the website and is returned when i do the search. Regards.

  • Using the BDC API how to catch the returned code when executing a stored procedure?

    using BDC API, how can i catch the return code a stored procedure returns?

    I tried Entity.Execute to execute a generic method. However, it returns an empty Entity table.

    I know you can do it by setting up an output variable. I prefer returning an integer for tracking errors.

    Any ideas?



    Display last inserted column value in the Form and concurrent updates


    1) I have a ORDER form which is a usercontrol(webpart in sharepoint)

        the first field is a autogenerated column given as ORD01,ORD02,ORD03...

        for this i have a column in the list which stores these values into list after user submits data.

        Now i want to show last inserted ORDER + 1 in the first field .

        i.e., when user opens this ORDER page it should show the value.

    2) the second case would when user submits data simultanoeusly.


    Can anyone suggest a solution for this



    Loop for every record


    Hi guys.

    I've got a simple table with an ID, a NAME and an ARCHIVE booleen.

    I want to write piece of code that goes through each record and...

    If ARCHIVE is false and a folder hasn't been created for it, it will create it and go to the next record.

    If ARCHIVE is false and a folder has been created for it, it will do nothing and go to the next record.

    If ARCHIVE is true the whole folder will be moved to another folder and go to the next record.

    When all records have been checked, the code will end.

    I was thinking of using a SQL count to find out how many records there were and making a loop that starts at record one. runs the folder checking/creating/archiving code then +1 until the loop ends but I couldn't work out how to assign the query results to an integer...

    I'm not asking for anyone to write the code. I think I probably already know 80% of the theory behind doing this I just can't glue it all together. I know you can do the folder stuff with the System.IO Directory Class...

    Anyway, all input is welcome. Cheers guys!


    Disregarding updates on non-checked-in entries in a sharepoint list (SPAudit)


    Hey guys.

    Okay, this is a little hard to explain, as the title might suggest.

    I have an event receiver on ItemUpdated and ItemCheckedIn, which both writes custom SPAuditEntries. When CheckedIn occurs though - it comes with two update entries as well (one for added file, and one for a simple update to the list item I suspect).

    I'd love to get rid of these entries. At first I thought it would be really simple, just put an if in the itemUpdated event receiver, and stop everything

    if(SPListItem.CheckedOut = false) { //... do nothing }

    However I couldn't find any way to ascertain the checkout-status of the listitem. My next thinking was, they hit almost at exactly the same time, so I could just crawl into the auditCollection, filter down to the specific listitem, user, and time (minus a second) and delete the two entries. But, sadly I found out I couldn't delete auditentries.

    Anyone got any ideas?

    Executing Command Logic in a View Model

    Through the use of the Windows Presentation Foundation's (WPF) advanced data-binding capabilities, the logical structure of a user interface can relatively easily be disconnected from its presentation. Bindable components can now contain nearly all of an application's user interface logic and in most circumstances, replace the need for controller objects from the classic Model-View-Controller (MVC) pattern. So it's no wonder that a new pattern for UI design has appeared

    Video: SharePoint 2010: Executing Code in the Sandbox

    Find out how the Sandboxed Solutions Service provides for a complete isolation system that ensures code running in a sandboxed solution cannot reach out to access information beyond the scope of the deployment. (Length: 12:01)

    Loop with DataReader


    Hi.  I am having a really hard time with this code trying to loop through a datareader, and then enter the data into another table.  The logic is that I get 2 columns path and document_no from an Oracle Database.  I then need to check if the file in the path column is a valid path.  If it is not valid, it should be inserted into a SQL Server 2005 database.  My code is below, can anyone help?  I'm getting a headache from it.  If any further info is needed just let me know.  Thanks. 

    Do While oraReader.Read()
                    path1 = oraReader("Path")
                    docno = oraReader("Document_No")
                    If (System.IO.File.Exists(path1)) Then                    
                        sqlCmd = New SqlCommand("INSERT INTO CHECKLINKS1 (DOCUMENT_NO) VALUES (@doc)", conn)
                        sqlCmd.Parameters.AddWithValue("@doc", docno)
                    End If


    Case statement is never executing


    Can some please advise as to why the case statement is never running


    Imports Microsoft.VisualBasic
    Imports AjaxControlToolkit
    Public Class MultilevelAccordion
        Inherits System.Web.UI.UserControl
        Implements System.Web.UI.ITemplate
        Dim templateType As AccordionItemType
        Sub New(ByVal type As AccordionItemType)
            templateType = type
        End Sub
        Sub New()
        End Sub
        Public Sub InstantiateIn(ByVal container As System.Web.UI.Control) _
              Implements System.Web.UI.ITemplate.InstantiateIn
            Dim ph As New PlaceHolder()
            Select Case (templateType)
                Case AccordionItemType.Header
                    Dim myLabel As Label = New Label()
                    myLabel.ID = "HeaderLabel"
                    AddHandler ph.DataBinding, New EventHandler(AddressOf Item_DataBinding)
                Case AccordionItemType.Content
                    AddHandler ph.DataBinding, New EventHandler(AddressOf Item_DataBinding)
            End Select
        End Sub
        Shared Sub Item_DataBinding(ByVal sender As Object, ByVal e As AccordionItemEventArgs)
            Dim ph As PlaceHolder = CType(sender, PlaceHolder)
            Dim headerValue As String = _

    how to get current loop order number in "for each" ?

    For Each item As pages.tbl1Row In pagesdim x as integerx = ?????response.write("current loop is :" & x )               Nextwhat code i need to replace with "?????" to get current loop order?
    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