.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

Updating bunch of records at time

Posted By:      Posted Date: September 15, 2010    Points: 0   Category :ASP.Net
Hi, If I want to update 1000 records at a time in the database what is the best approach.Guide me Pls.

View Complete Post

More Related Resource Links

Updating Multiple records at 1 time.


You got to love management, they can never make their minds up on what they want. 

I'm currently working on a asp.net project using a datagridview that acts for the most part like a spreadsheet.  What I have to do now is update all the values in the table from the selected date, hour, min, max and cost forward.  There are 7 days worth of data in the table, when the user alters either the min, max or cost I need all the values in that field from that point onward to have the new altered value.

Here's an example:

In hour 10 of the day the user want to increase the max from 5 to 19, the min stays the same and so does the cost.  Mind you any or all of these values could change.  The only once that will remain as-is is the Date and Hour field:


Date Hour

Timers: Implement a Continuously Updating, High-Resolution Time Provider for Windows


The timestamps that you can obtain from Windows NT are limited to a maximum resolution of 10 or 15 milliseconds, depending on the underlying hardware. At times, such as when you need to timetag frequent events, it is desirable to achieve a higher resolution. For example, what if you want to be able to contact a thread or perform some other task at intervals more frequent than 10 milliseconds? Suggested ways of achieving better resolution include using performance counters in conjunction with the sytem time to calculate smaller time increments. But using performance counters is a technique that presents its own problems. This article shows one possible way of overcoming limitations inherent in this approach.

Johan Nilsson

MSDN Magazine March 2004

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

Select random 10 records in sql server 2005 in terms of time

Hello,i have a query that select random records in access database in terms of time : "SELECT TOP 10 * FROM Tbl ORDER BY Rnd(-10000000*TimeValue(Now())*[ID])"now i wish to convert this query for using in sql server 2005 such that return random records in term of time 

Update statement not updating records and returns no errors

I am running an Update statement against an SQL database on server 2008. The update runs but does not update the record, but returns no errors. The database is part of a commercial help desk package called TrackIt 8.5 which was just a fresh install on a new web server and a new sql server. The update is running from a web form we use to automatically create active directory accounts. After the account is created the web form closes out the work order in the Trackit db. This was working fine when the system was running on Server 2003 and SQL server 2005. Running Trackit version 7.02. The login use to access the database has full permissions to read and write to the database, just as it did on the old server which never had an issue updating. Odd thing is, if I log onto the SQL server and make a change to any single field in that record. I can then run the web form and it updates the record normally. All other update statements that are running on other databases are running fine. Anyone have any suggestions on what to check that may be causing this issue?

SELECT Random Records in term of time



I want to return random records in term of time whithout NEWID

Insert on button event is inserting 2 records at a time


I have a form that is doing a simple insert, then a sub insert of a certain drop down selection is made. What i dont get is why the main insert is inserting duplicates and the sub works fine inserting 1 record per text as expected. I click the button 1 time, and when i check the table, there are 2 new records.. As you can see the insert is not wrapped with any conditions, once that is inserted i check if a slection was made and runs the sub insert.

My full code can be found in this post(http://forums.asp.net/t/1608619.aspx), but here is what i have for my button event.

    protected void btnSaveServConfig_Click(object sender, EventArgs e)   
        dac.insertServerConfigintosql(txtEmailLogin, txtEmailPass, Convert.ToInt32(ddlNumEmail.SelectedValue));   
            if (Convert.ToInt32(ddlNumEmail.SelectedValue) > 0)   
                 Dictionary<string, string> camValues = new Dictionary<string, string>();   
                    foreach (HtmlTableRow row in table1.Rows)   
                        foreach (HtmlTableCell cell in row.Cells)   
                            foreach (Control control in cell.Controls)   

Inserting/updating DB looping Excel data of huge number of records




    I have requirement to read the excel data and based on some conditions ih ave either insert/ update the data in to Oracle tables. to check the condition I have to loop through the 4 columns for 4 conditions which may consist of huge number of records, where performance issue arise here. please put me in the right way or suggest me a best approach to break through the performance issue as well.

ofcourse i am writing in a service.

Finding records using time datatype


I need to find rows in a table that have StartTime and EndTime that fall between sent start and end time parameters.  Below is the design of the table I want to search and below it is an example of a SELECT statement.  I need to add to the SELECT another condition (e.g. AND StartTime BETWEEN @StartTime AND @EndTime OR EndTime BETWEEN @StartTime AND @EndTime).  Any help is appreciated.

CREATE TABLE [dbo].[CareScheduleDetail](
 [CareScheduleDetailID] [int] IDENTITY(1,1) NOT NULL,
 [CareScheduleID] [int] NOT NULL,
 [WorkDay] [tinyint] NOT NULL,
 [StartTime] [time](7) NULL,
 [EndTime] [time](7) NULL,
 [SvcType] [varchar](4) NULL,
 [Effective] [date] NULL,
 [Ended] [date] NULL)


SELECT     WorkDay, StartTime, EndTime
FROM         dbo.CareScheduleDetail
WHERE     (Ended IS NULL)

updating multiple records



need some help creating a stored proc to update n records based on user choice. so if user decides to enter 3 vouchers i create 3 text boxes and when button click should check if all the vouchers exsits and then update all of them. the problem is that if user enters one wrong voucher and two correct the update takes place for those two and i handle the error based on condition so it confuses as it return and error. here is what i have:





If DDL1V =

Need to query three records at a time.


I need to write a select that pulls all of the rows from a data table but the problem is that I need to get the rows three at a time.

I am querying SharePoint data and since SharePoint only allots so many fields per record per data type, my list has three rows for every list item. So in order to sum fields 1-31 of loat data I actually need to grab row instance 0, 1, and 2.

For each list item field float 1-12 holds 1-12 in row instance = 0 and float 1-12 holds 13-24 in row instance = 1 and float 1-7 holds float data for 25-31 in row instance = 2. The field name of the row instance is . I need to sum fields float1-float12 for the three rows and get one total.

Normally I would use something that summed the 12 float fields and assign it to one variable field to be returned in the select. But I have to loop through the three rows to get that for each and then sum the subtotals of the three rows adn repeat until eof.

Can anyone give me a pseudo code for the select? I am just not that fancy with SQL I guess.

You can assume that there are always exactly 3 rows for each item whether or not there is data in any of the given fields. If the field has no positive data it is recorded as NULL in the field.

Thank  you in advance to any with ideas.


C#: How to store real-time updating measurements in a database (C#)

I have real-time updating measurements (for each second some new values).

Task: I have to store these real-time updating measurements in a database.

Question: Since I am working with C#, I have 2 basic questions:
(1) How to store real-time updating values in C# (within in database framework)?
(2) Should I use MySQL as database?

Thanks in advance,

Round off time to the nearest minute

How would you round this up to the nearest minute? There isn't a built in function to do this so you have to use a little bit of maths to get there. There are 60 seconds in a minute. We already have 38 seconds on the clock. So we need to add on 60 - 38 = 22 more seconds.

ASP.NET GridView - edit records using JQuery Dialog

There are many ways in which you could modify modular data in Grid View:
1. Inline by making rows editable when u click on Edit
2. By using separate pages for Edit
3. By using popups/dialogs for adding/editing

Performance Tests: Precise Run Time Measurements with System.Diagnostics.Stopwatch

Everybody who does performance optimization stumbles sooner or later over the Stopwatch class in the System.Diagnostics namespace. And everybody has noticed that the measurements of the same function on the same computer can differ 25% -30% in run time. This article shows how single threaded test programs must be designed to get an accuracy of 0.1% - 0.2% out of the Stopwatch class. With this accuracy, algorithms can be tested and compared.

Date and Time Functions in SQLSERVER

Date and time functions allow you to manipulate columns and variables with DATETIME and SMALLDATETIME data types.

1 DATEPART Function
2 DATENAME Function
3 DAY, MONTH, and YEAR Functions
5 DATEADD Functions
6 DATEDIFF Function
7 More SQL Server Functions

Data Types - Date and Time in SqlServer

Date and time values can be stored with either the DATETIME or SMALLDATETIME data type. The difference between the two is that SMALLDATETIME supports a smaller range of dates and does not give the same level of precision when accounting for time. The DATETIME data type can hold values from January 1st of 1753 to December 31st of 9999. The time is stored to the 1 three hundredths of a second and each value takes up 8 bytes of storage. The SMALLDATETIME data type can hold values between January 1st 1900 and June 6th of 2079. The time is tracked to the minute and each value takes up 4 bytes of storage. The majority of business applications can live happily with SMALLDATETIME, however, if you are in an environment where each second matters or you need to make estimates to the distant future (or past) then you have to resort to DATETIME. If you fail to specify the time when inserting a value into a DATETIME or SMALLDATETIME column, a default of midnight is used. If you fail to specify the date portion the default of January 1, 1900 is used.
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