Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations Wanet Telecoms Ltd on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

Update database from dataset

Status
Not open for further replies.

lunchbox88

Programmer
Feb 17, 2004
208
US
I'm pulling 2 columns from a table on a SQL Server database in to a dataset, the ID, and a charfield. The char field has to be 10 characters, so I'm checking the length, and appending leading 0's where necessary.

What's the fastest way to write the changes back to the table in the database? There's about 250,000 records.
 
I think you can do this wothout having to load all of your data into a dataset. Just execute a SQL UPDATE command using the LPAD function:

UPDATE <tablename> SET <charfieldname>=LPAD(<charfieldname>,10,'0')

Let me know if this works.


I used to rock and roll every night and party every day. Then it was every other day. Now I'm lucky if I can find 30 minutes a week in which to get funky. - Homer Simpson
 
Thanks! I'll give that a shot. I was asking because this isn't the only manipulation I'll be doing, so I was wondering the quickest way to write the changes back to the database. Some of the other stuff I'll be doing is checking two to three fields in two to three different tables to update a field in one table.

So I still need to know the fastest way to make changes from a dataset back to the database.

Thanks again
 
Well, depending on the relationship between the tables, you should be able to do this with SQL also, with no need of a dataset.

Also, have you looked into doing this with triggers and/or stored procedures in SQLServer?



I used to rock and roll every night and party every day. Then it was every other day. Now I'm lucky if I can find 30 minutes a week in which to get funky. - Homer Simpson
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top