SQL Server :: Updating Bunch Of Records At Time?
Sep 15, 2010If I want to update 1000 records at a time in the database what is the best approach.
View 6 RepliesIf I want to update 1000 records at a time in the database what is the best approach.
View 6 RepliesI have two tables for storing language translations - tblEN and tblES. They have the same structure which is nvcEnglish and nvcLocal - both nVarChar fields.
In nvcLocal of the Spanish table, I enter the Spanish translations of words and phrases used within my app. Problem is, when I add a bunch of new records to the English table I also have to go in and repeat the data entry into the Spanish table. I am wondering if there is a way to import the newly added records into the Spanish table using Transact SQL?The plain language query would be something like:
If the data in tblEN.nvcEnglish does not exist in tblES.nvcEnglish then insert a new row into tblES with the values from tblEN
I'm trying to delete a bunch of records in mysql. The record info to delete (userid, name) is stored in an arraylist. It seems to only delete the first record and gives an error ("Transaction has already been rolled back or is not pending.") afterwards. I have the transaction commit inside the loop which I think is the issue but not sure how to go further if I bring it outside of the loop. Here's the relevant bits of the code.
try
{
ArrayList alist = new ArrayList();
//alist gets populated with data like (12345,robot)(23456,car) here.
MySqlConnection conn2 = new MySqlConnection(query_connection);
conn2.Open();
MySqlCommand command2 = conn2.CreateCommand();
MySqlTransaction mytransaction;
mytransaction = conn2.BeginTransaction();
command2.Transaction = mytransaction;
for (int i = 0; i < alist.Count; i++)
{
string[] s = alist[i].ToString().Split(',');
try
{
command2.CommandText = "DELETE from users_settings WHERE UserID=" + s[0].ToString();
command2.ExecuteNonQuery();
command2.CommandText = "DELETE from users WHERE ID=" + s[0].ToString();
command2.ExecuteNonQuery();
mytransaction.Commit();
}
catch (Exception e){
mytransaction.Rollback();
}
}
}
catch(Exception e){
}
I'm trying to send a bunch of looped records from database to javascript array in codebehind to add overlays to the googlemap markers. So farthe code below only provide me the first marker.
PHP Code:
private void BuildScript(DataTable tbl)
{
String Markers = "";
foreach (DataRow r in tbl.Rows)
{
[code]...
I hope to one day figure this looping records from a table to update it, but i cannot get this to complie, I guess cause I am not
versed in looping in sql yet :(
[Code]....
I just want to get data from a table per record run the stored procedure(i have nesting on) and update the record's fields with the values that were returned from the Store procedure. The Stored procedure is working fine.
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.
View 3 RepliesI have a requirement that user can enter data into a table only once in two date and time ranges in a day as:
from 6 AM to 5:59 PM and from 6 PM to next day till 5:59 AM.
for Example:if today 25/ Nov/2010 at 9:45 AM i have entered a record then if i again try then can not enter the record in table till 5:59 PM but i can enter again today after 6:00 PM till 26/Nov/2010 - 5:59AM.
I want to return random records in term of time whithout NEWID
View 5 Repliesi 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
View 5 RepliesI have a web portal designed in ASP.NET in which we ask customers to enter the data. On the click of submit button all i have done is, just read the data and called a stored procedure which inserts that into a table. There seems to be a problem in SQL Server 2005 while inserting the data from multiple computers at the same time. We have tested in our lab with three computers, result is that we get the data inserted successfully in only one machine and on the other two machines we get error on page. I have used transactions in the stored procedure and also tried setting the isolation levels to READ_UNCOMMITTED, SERIALIZABLE and SNAPSHOT. Nothing seems to work properly.
View 4 RepliesI used to work in the IT field, but because of an accident and meds I have lost a bunch of my memory. So, I'm in need of relational database help..I've got a web site I want to put up that will sell books. I'll be using SQL server 2008. I'll be using Pay Pal's Cart, etc, so I just have to put up some buttons on the web site, but I need to track, display, etc, the books and properties about the books such as Authors, Paper back or hard cover, first edition, or something else, etc,..I have a table for books obviously, but I'm wondering if I should break out the Authors out of that table? I mean I don't see why except that if I end up with some books that have the same author then there names will be stored more than once, but I will be doing a lot more queries than inserts. I've got Customers, Book Types which is if the book is a hard cover, softcover, first edition, etc,. I will relate the Books to the Book Types of course, but again, should I have an authors table? Hope this makes sense.. I am using Visual Studio 2008 Pro, and want to do my relations there, so I thought I'd do so in the IDE if possible? I can't remember, but I thought it was possible?
View 6 RepliesMy 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.
[Code]....
[Code]....
The website is over half way done and the functionality for the blog is (except for adding posts) is already implemented and working correctlyI have a SQLExpress 2008 backendBlog posts are rendered on the page with full HTML markup within a label control.
All of the above is done and working. Though I am essentially new to creating websites with ASP.NET, CSS and SQL, I am sure that I could simply carry on and make a login page with some controls that would allow me to add records (blog posts) directly to the database on the host server. However, I am fearful of doing this because I know that malicious code can be passed in this way. Also, because of my lack of knowledge, the only way that I know of to pass the code from a control to the database is to disable validation for the page the control is on. Without a doubt I do not want to do that.
So what are my options for getting blog posts into the database? Is it safest for me to fully create the post in html and update a copy of the database that resides on my local machine? If I do it this way, how can I merge the records from the database on the local machine with the records on the remote server?
i m preparing a website based on asp.net forums .i have made all the forms reg., login , etchow to get the main grid which is on forums page.how to keep that updating every time.
View 2 Replieseasiest way to create/update a parent and child record at the same time (like customer with multiple addresses) with least or no code as possible? Both Web Forms and in MVC.
View 1 RepliesWe have an asp.net website running on IIS 6 Windows 2003. When ever we upload a class file to the App_Code folder our whole site goes down temporarily until, what I assume, compilation is complete. Has anyone else experienced this? Any other file we upload it does not do this only our class files.
View 1 Replies in this scenario if if i bring all the records at once from this query
var pages=_db.Pages;
and then i will process according to some scenario
pages.Where(m => m.int_PostStatusId == 2)
pages.Where(m => m.int_PostStatusId == 3) and so on
is it really saving some processing time? or not (what really to do ?)
i have 4 dropdownlist controls in a page. each have more than 6000 records. when retrive the records from DB there is no issue and taking very less time. after getting the records it takes too much time to display in the the page. here no problem with db retriving.. i guess problem is with page weightage. how can i solve this problem..
View 3 RepliesI am building a small mass email application for my department. Which basically emails out a notice to a large list of email addresses. Because the company email server limits the amount of email addresses that can be contained in a single email I have to break the list apart into smaller 100 email groups.
I've create the query to pull all email addresses needed, stuffed them into a collection but I am not sure how to grab 100 emails at a time and send it off to another sub to perform the email send before grabbing the next 100.
This is what I have so far.
[Code]....
I am using dataset which contains some records I want to query with dataset to get every time next 20 records. I don't want to do it throught loop is there any way that I can get next 20 records everytime.
View 5 RepliesLet say you read a customer record into Customer object. Do it read all the related records across tables at the same time Or it only reads when you do from o in customerobject.orders
View 2 Repliesarticle on binding to a list and I've got that working fine on one view. But what I'm stuck when doing it off a master record. Everything seems to work except that when I look in the database the detail records previous associated with the current master have their Foriegn key to master set to Null and a new set of detail records have been inserted. I've got a really simple form for this object
[Code]....
The form collection comes back with the expected prefixes:
[Code]....
And the Controller.UpdateModel(master) binds all the properties correctly. But when I call dbContext.SaveChanges it issues the follow sql from sql profiler (psuedo code)
[Code]....
I've got a work around that works but it's pretty hackish and I'm currently not matching up the keys so it's dependent on everything coming back in the right order. Plus I've got to include all the fields that I want updated.
[Code]....
I thought that entity framework's code first was the culprite but I've unit test that and it works fine. I've got a feeling that UpdateModel is somehow removing and re-adding the children. Has anyone else got this to work? Of course, I could throw in the towel and parse the indexed field names myself, but I'm so close!
I am trying to get my repeater to display information 10 records at a time for a single page with the user having the option to press next to view the next 10 pages or previous to review the previous 10 records with the option to skip pages by clicking the navigation links 1 | 2 | 3 | 4 | 5 is this possible?
Does it have to be alot of code as I have done it sort of already with an array and 5 repeaters? do arrays such as string[] a work when being hosted?
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 [URL], but here is what i have for my button event.
[Code]....
I want to port an existing, legacy, ecommerce website from ASP to ASP.NET.What approaches do I have ?is there a way to run an ASP file with an ASP.NET engine ?are there tools to automatically convert ASP to ASP.NET and do they work on complex websites
View 3 Replies