473,395 Members | 1,631 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 473,395 software developers and data experts.

How to update multiple records with 2 tables involves?

1
Hi everyone! I'm new in this forums and new in the line of programming..A Beginner.. I have a problem, I don't know how to populate a multiple updates. Anyone who have codes for this?

Here's the scenario:

have 2 tables, one is table named as “STARTS” with field name avail,uph,yearly_starts.(52*7*24*uph*avail). Other table is named as “THROUGHPUT” with field name process_name,step_yield(%),yearly_throughput.

Uph = 1420
Avail = .8
yearly_starts = (52*7*24*uph*avail)

The scenario of getting the yearly throughput is here:

process_name----step_yield(%)----yearly_throughput
0-----------------------100----------------9924096-->which is the yearly_starts * step_yield
1-----------------------99.8---------------9904248-->which is the yearly_throughput of process_name 0 * step_yield
2-----------------------94-----------------9309993-->which is the yearly_throughput of process_name 1 * step_yield
3-----------------------97-----------------9030693-->which is the yearly_throughput of process_name 2 * step_yield
.
.
23 and so on..........................................


I have a update command for the "STARTS" table, and I would like to add the update code for the "THROUGHPUT" table inside this code. So everytime that the "STARTS" table updates, it also update the "THROUGHPUT" table.

Protected Sub Update_Click(ByVal sender As Object, ByVal e As DataListCommandEventArgs) Handles DataList1.UpdateCommand


Dim calc As New mcCalc6()

Dim tavail As TextBox = CType(e.Item.FindControl("txtavail"), TextBox)
Dim tuph As TextBox = CType(e.Item.FindControl("txtuph"), TextBox)
Dim tystarts As TextBox = CType(e.Item.FindControl("txtystarts"), TextBox)

If tystarts.Text <> "" Then

tystarts.Text = calc.evaluate(52 * 7 * 24 * tavail.Text * tuph.Text)

End If


Dim tbox As TextBox
Dim avail As String
Dim uph As String
Dim ystarts As String
Dim info As String
Dim lbl As Label



tbox = CType(e.Item.FindControl("txtavail"), TextBox)
avail = tbox.Text
tbox = CType(e.Item.FindControl("txtuph"), TextBox)
uph = tbox.Text
tbox = CType(e.Item.FindControl("txtystarts"), TextBox)
ystarts = tbox.Text
tbox = CType(e.Item.FindControl("txtid"), TextBox)
ID = tbox.Text
lbl = CType(e.Item.FindControl("lblinfo"), Label)
info = lbl.Text


'---updates the database--

Dim strConn As String = "data source=WEBSPM\WEBSPM;Initial Catalog=cost;User ID=password;Password=password"
Dim conn As New SqlConnection(strConn)
Dim strUpdate As String
Dim cmdUpdate As SqlCommand
Dim intRecordCount As Integer

strUpdate = "UPDATE starts SET avail='" & avail & "',uph='" & uph & "', yearly_starts='" & ystarts & "' where id='" & ID & "'"
cmdUpdate = New SqlCommand(strUpdate, conn)

conn.Open()

intRecordCount = cmdUpdate.ExecuteNonQuery()

conn.Close()
lbl.Text = intRecordCount & " " & "records updated!"


End Sub


I hope that you could help me with this. Thank you so much.

Sincerely,
Jayz
Dec 6 '06 #1
1 1539
bplacker
121 100+
open up another dataadapter for the second table, write another update query, and execute it at the same time. You cannot execute multiple table updates on one data adapter, it doesn't know what to do with that.
Dec 6 '06 #2

Sign in to post your reply or Sign up for a free account.

Similar topics

33
by: Lee C. | last post by:
I'm finding this to be extremely difficult to set up. I understand that Access won't manage the primary key and the cascade updates for a table. Fine. I tried changing the PK type to number and...
4
by: Mike Dole | last post by:
I might have taken a wrong turn trying to do an update on a database the way I did but maybe somebody can help me out cause I'm stuck.. I have to update 12 tables in a database in a client...
8
by: Greg Peck | last post by:
Hi I need to update a field (fldX) in one DataTable (dt1) where there is a match on fldA in another DataTable (dt2). Is the only way to do this by itterating through the DataRows of dt1,...
1
by: AndiSHFR | last post by:
Hi. How do i "bulk update" data rows on a dataset table from another one DataTable? i have a dataset ds1 with a table "Groups" and a table "newgroupdata" and i want to update the records in...
5
by: JP SIngh | last post by:
Hi All This is a complicated one, not for the faint hearted :) :) :) Please help if you can how to achieve this search. We have a freetext search entry box to allow users to search the...
2
by: bobabooey2k | last post by:
I have an update query with one field having in its "Update to" cell a DLookup statement. This query takes 2-3 minutes on 3000 records. Can I avoid dlookup here using multiple queries? An...
1
by: Hexman | last post by:
Hello All, What I'm trying to do is update a child record using a parent-child relation. I want to find out if it is faster than than doing multiple selects. Anyways, I've created a dataset...
0
by: Access Programming only with macros, no code | last post by:
ERROR MESSAGE: Could not update; currently locked by another session on this machine. BACKGROUND I have the following objects: Table1 - HO (which has about 51,000+ records) Table2 -...
1
by: DMAGIC448 | last post by:
I am trying to figure out how to add records to multiple tables w/ one form. I am making a database for a Home DayCare and I want to add/update records for 5 tables (Student info, Parent 1 Info,...
0
by: ryjfgjl | last post by:
If we have dozens or hundreds of excel to import into the database, if we use the excel import function provided by database editors such as navicat, it will be extremely tedious and time-consuming...
0
by: ryjfgjl | last post by:
In our work, we often receive Excel tables with data in the same format. If we want to analyze these data, it can be difficult to analyze them because the data is spread across multiple Excel files...
0
by: emmanuelkatto | last post by:
Hi All, I am Emmanuel katto from Uganda. I want to ask what challenges you've faced while migrating a website to cloud. Please let me know. Thanks! Emmanuel
0
BarryA
by: BarryA | last post by:
What are the essential steps and strategies outlined in the Data Structures and Algorithms (DSA) roadmap for aspiring data scientists? How can individuals effectively utilize this roadmap to progress...
1
by: Sonnysonu | last post by:
This is the data of csv file 1 2 3 1 2 3 1 2 3 1 2 3 2 3 2 3 3 the lengths should be different i have to store the data by column-wise with in the specific length. suppose the i have to...
0
marktang
by: marktang | last post by:
ONU (Optical Network Unit) is one of the key components for providing high-speed Internet services. Its primary function is to act as an endpoint device located at the user's premises. However,...
0
Oralloy
by: Oralloy | last post by:
Hello folks, I am unable to find appropriate documentation on the type promotion of bit-fields when using the generalised comparison operator "<=>". The problem is that using the GNU compilers,...
0
jinu1996
by: jinu1996 | last post by:
In today's digital age, having a compelling online presence is paramount for businesses aiming to thrive in a competitive landscape. At the heart of this digital strategy lies an intricately woven...
0
tracyyun
by: tracyyun | last post by:
Dear forum friends, With the development of smart home technology, a variety of wireless communication protocols have appeared on the market, such as Zigbee, Z-Wave, Wi-Fi, Bluetooth, etc. Each...

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.