ADO.NET :: Can Bulk Update Using Linq
Dec 23, 2010have the DataTable having thousands of record ,I need to modify the rows using some c# function,I do not want to iterate through each row.So how can I use linq for it.
View 3 Replieshave the DataTable having thousands of record ,I need to modify the rows using some c# function,I do not want to iterate through each row.So how can I use linq for it.
View 3 RepliesI have to update the users based on input value..
here is my code..
[Code]....
using this I can update only one user perfectly but I need to loo update all users based on generic Filedset values?
Lets say i have a button control on a page and a label control. On clicking this button it performs series of actions say Action 1 , Action 2. Action 20 which will take say approx 1 hour to complete. What i need is, once this long processing is started, My web page should show the status of each action on label. Eg. After clicking a button, Label1 text should be "Action 1 is started" after Action1 is completed and Action 2 is started ,.... Label1 text should be "Action 1 Done...Action 2 started" I need this so that my user can see whats the current state of processing.
View 7 Repliesis it possible to do a batch update in a strongly typed data set? UpdateBatchSize does not seem to be an option once you create a strongly typed dataset.
View 1 Repliesi have a requirement like we bind data in to gridview..once we click on edit field i should be ale to edit in a form...this is all in a website...
in the gridview we will have textfields,dropdown fields,image upload fileds...once edit is clicked all the fields need to be edited..
how to bulk update a temp table with the sum of another query. for example
update @temp
Set total =
(
select sum(bedstays)
from @temp2
WHERE @temp2.ID = @temp.ID
)
i keep getting error in sub query on the @temp.ID saying i need to declare @temp and when i alias @temp "@temp t" i get an incorrect syntax near "t".
I have a gridview with checkboxlist for each record. I was updating each record individually based on that check, but now they want it to be a bulk update instead of individual. So i have commented out my individual update and added a button below the gridview and created my button event, how to loop thru the gridview and find the checked records and call my update procedure.
i found something kinda close to what i need, but its in VB and not sure how to convert that to C#
[URL]
I select few columns from table A in dataset. Example "EMP_ID","Name","Address","Phone_Number". I want to save data in this dataset into some other table B.
I want to save data from dataset into table B. But i want to have following functionality
1. Before saving a record from dataset to table B if that record if previously present in table B, if yes then check if any value are different, if yes then update that record with the record from dataset, if all the values are same then leave the records as is.
2. If the record is not present in table B then insert it new records in table B from dataset.
Is there any efficient way to implement in .NET C#.
i have a form in which when i enter value and upon pressing submit button all the data were shown
on the grid.from where i can edit and update the grid view. in this case i can edit the only particular row. but i want to edit the whole grid and then update it. means bulk edit
Share the code regarding bulk edit and update according to my above mentioned code.
How to do bulk edit/update with checkboxes in GridView control where in the selection of editting a row needs to have some info brought from db for validation on update?
View 10 RepliesI have my gridview and its code is as follows
<asp:GridView ID="noticeDetails" runat="server" EmptyDataText="Currently there are no notifications." BorderColor="White"
BorderWidth="1px" AutoGenerateColumns="false" PageSize="10" Width="100%" CellPadding="10">
<Columns>
<asp:BoundField DataField="CampaignIDRange" HeaderText="CampaignIDRange"
SortExpression="CampaignIDRange" InsertVisible="False" ReadOnly="True" />
[Code] ....
I want to add a Edit button at the end of the grid view upon clicking on that button i can edit the grid columns.
Any method to resolve this query.
I'm having a gridview in my aspx page with checkbox, User can select one or more than one record(s) at a time and clicks on delete button, Then i'm constructing an object of my DTO and adding all the checked row's Primary Key (DataKeyNames - GUID's in my case) to a serializable class and generating an XML and sending it as parameter to the Stored Procedure.
My Doubt is, can i bulk delete all the rows from database table those are present in my XML document??
If it works, I can do bulk update with XML only, i already did bulk insertion by generating an XML..
My Another Question is, Will it affect the performance? Each time when i construct an DTO object and adding it to the Generic List?
Which one is better, I mean ObjectDataSource or SQLDataSource or my XML method?
[code]....
When processing many records starting from 10,000 System.OutOfMemoryExceptio get the error. There would be some way to handle this type of memory error ?.
ASP.Net SqlBulkCopy- Bulk Insert records and Update existing rows if record exists Exception: Out of Memory Exception C# and VB.Net
I need a way of doing the following:
I receive data in .csv format. I have a some records on a table, so what I need to do is to check if the data I receive exist on the table of records that I need to match against.
If the record exist, then an email/sms should be sent to notify me that the records has been matched and then that record should be flaged that it has been tested so that I don't test it again as the incoming data are saved.
I have a set of dataset with different column retrieved from DB. I need to present the datasets in one GridView (or other ListView etc...) without specifying the column_header. It should present automaticly since the GridView is bind to the DataSet.
In additional, I want this GridView to handle multiple rows edit and update the dataset, idealy, show data in textboxs in initially.How could I set the GridView to edit_model without hardcode column_header and textboxs in 'itemtemplate' or filed.
How could I achieve the bulk edit and update, so that I can assign 'mydataview1.table' to the dataset.
I have to update teh database table using Linq.
The table has max 1 row sometimes no rows at all, below is my code, but it throws error.I amm very new to Linq
protected void btnSave_Click(object sender, EventArgs e)
{
var pss = new PrintingServiceDataContext();[code].....
My controller:
[HttpPost]
public ActionResult Deposit(DepositTicket dt)[code]....
Where the comment "Update Query" is, is where I want to add an update query to updated the Account table with an Account object. I want to update the exisiting record, can this be done using the predefined functions for db.Accounts or would I have to write a linq query?
I'm using linq to sql to on a recent project. So was wondering if anyone could provide any advice as to why this code doesn't update the database? The problem seems to be that the value from the textbox isn't persisted when I click the submit button in the gridview.
[Code]....
I use Linq to Entities and want to update and delete data. I know the ID of the object / record.
How can update and delete without first selecting the complete object (asuming that this is better for performance)?
Currently I update a single item in a database as follows:
var master = (from tmi in db._Masters where tmi.Id == Id select tmi).FirstOrDefault();
master.logPosition++;
db.SubmitChanges();
This strikes me as inefficient, as (I think) I am pulling out a full DB row to just update a single value. Is there a more efficient query I can use?
How can I update an existing LINQ entity? This code gives me: "Cannot insert an entity that already exists."
Any better practises on updating/inserting with linq?
foreach (ListViewItem lvi in lvStudents.Items)
{
HiddenField hfStudentID = lvi.FindControl("hfID") as HiddenField;
CheckBox cbPresent = lvi.FindControl("mycb") as CheckBox;
int sInt = Int32.Parse(hfStudentID.Value);
dc = new DataClassesSODataContext();//I renewed the dc to make sure that wasn't the problem?
var currStudent = dc.students.Single(x => x.studentID == sInt);
grade g = dc.grades.Single(x => x.subjectID == subjID || x.studentID == sInt);
if (g == null)
{
g = new grade();
g.subject = dc.subjects.Single(x => x.subjectID == subjID);
g.student = currStudent;
g.present = cbPresent.Checked;
dc.grades.InsertOnSubmit(g);
} else
{
g.present = cbPresent.Checked;
dc.grades.Attach(g, true);//I tried both attaching and inserting
}
}
dc.SubmitChanges();
Is there a quick and easy way to update my LINQ dbml files?Right now, if I update a Stored Procedure, I need to open the dbml designer file, delete the old SP, save, drag and drop the new SP, and save again. Dont' get me wrong, this isn't "hard"... just with all the fancy new technology out there, it would be nice to be able to just right-click and hit "update".
View 2 RepliesI am having a hard time attempting to update a single field without having to retrieve the whole record prior to saving.
For example, in my web application I have an in place editor for the Name and Description fields of an object. Once you edit either field, it sends the new field (with the object's ID value) to the web server. What I want is the webserver to take that value and ID and only update the one field. There are only two ways google tells me to do this:
1) When I get the value I want to change, the value and the ID, retrieve the record from the database, update the field in the c# object, and then send it back to the server. I don't like this method because not only does it include a completely unnecessary database read call (which includes two tables due to the way my schema is).
2) Set UpdateCheck for all the fields (but the primary keys) to UpdateCheck.Never. This doesn't work for me (I think) due to my mapping layer between the Linq to Sql and my Entity/ViewModel layer. When I convert my entity into the linq to sql db object it seems to be updating those fields regardless of the UpdateCheck setting. This might be just because of integers, since not setting an int means it is a zero (and no, I can't use int? instead).
I have tables two tables, the "book" and the "author", a book can have many authors and vice versa, so there is an intermediate table called "book_author" with two columns as foreign key for those two primary keys
book_author
book_id
author_id
I'm trying to edit the book details and also its author using the entity date model, The controller class method
[Code]....
The HTML edit form
[Code]....
I can only update the book table, but not author that the book has or the book_author, I'm new to asp.net, I can't easily find a tutorial on this issue, I think the logic is to delete the author of the book first and then add the author for that book, but I don't know exactly about that linq and C# code. Can show me? I can only update the book table, but not author that the book has or the book_author, I'm new to asp.net, I can't easily find a tutorial on this issue, I think the logic is to delete the author of the book first and then add the author for that book, but I don't know exactly about that linq and C# code.
I am setting the Address of a class generated by Linq 2 Sql and when I try to SubmitChanges(), the sql query it generates is:
Update Users
Set Address = @po
Where 0 = 1
--@po: Input VarChar (Size = 15; Prec = 0; Scale = 0) [123 45th Street]