473,385 Members | 1,872 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,385 software developers and data experts.

Update 2 different Tables from one record?

Is this possible:

Read fields(rows/columns) from one sql database table (TableA). Then edit/update the same 'field' in TableA; and in TableB edit/update a different field - all at the same time?

This is the current situation in an Access Form using Sql for the backend. We would like to convert this Access Form to a Web Form using Visual Studio.net and VB.net.

Please help. Thanks,
gthompson
Nov 18 '05 #1
7 1799
At the same exact time? No. You will need to do 2 separate UPDATE
statements. However, you can certainly do them one after the other.

--
HTH,
Kevin Spencer
..Net Developer
Microsoft MVP
Big things are made up
of lots of little things.

"gthompson" <gt*******@thebbpcompanies.com(donotspam)> wrote in message
news:07**********************************@microsof t.com...
Is this possible:

Read fields(rows/columns) from one sql database table (TableA). Then edit/update the same 'field' in TableA; and in TableB edit/update a
different field - all at the same time?
This is the current situation in an Access Form using Sql for the backend. We would like to convert this Access Form to a Web Form using Visual
Studio.net and VB.net.
Please help. Thanks,
gthompson

Nov 18 '05 #2
You could call one Stored Procedure that would in turn execute two Update
statements (one for each table.)

--
I hope this helps,
Steve C. Orr, MCSD, MVP
http://Steve.Orr.net
"gthompson" <gt*******@thebbpcompanies.com(donotspam)> wrote in message
news:07**********************************@microsof t.com...
Is this possible:

Read fields(rows/columns) from one sql database table (TableA). Then edit/update the same 'field' in TableA; and in TableB edit/update a
different field - all at the same time?
This is the current situation in an Access Form using Sql for the backend. We would like to convert this Access Form to a Web Form using Visual
Studio.net and VB.net.
Please help. Thanks,
gthompson

Nov 18 '05 #3
Even if the field in TableA is not the same field as in TableB? Example: "FinishDate" in TableA updates "NextPhase" in TableB.

"Steve C. Orr [MVP, MCSD]" wrote:
You could call one Stored Procedure that would in turn execute two Update
statements (one for each table.)

--
I hope this helps,
Steve C. Orr, MCSD, MVP
http://Steve.Orr.net
"gthompson" <gt*******@thebbpcompanies.com(donotspam)> wrote in message
news:07**********************************@microsof t.com...
Is this possible:

Read fields(rows/columns) from one sql database table (TableA). Then

edit/update the same 'field' in TableA; and in TableB edit/update a
different field - all at the same time?

This is the current situation in an Access Form using Sql for the backend.

We would like to convert this Access Form to a Web Form using Visual
Studio.net and VB.net.

Please help. Thanks,
gthompson


Nov 18 '05 #4
If using a stored procedure, sure.

CREATE PROCEDURE UpdateTables
(
@Value1 varchar(100),
@Value2 varchar(100),
@Value3 varchar(100)
)
AS
UPDATE Table1
SET Value1 = @Value2

UPDATE Table2
SET Value2 = @Value1

UPDATE Table3
SET Value3 = @Value3

GO

--
HTH

Kyril Magnos
"I'm not a developer anymore, I'm a software engineer now!" :-)

"gthompson" <gt*******@thebbpcompanies.com(donotspam)> wrote in message
news:2E**********************************@microsof t.com...
| Even if the field in TableA is not the same field as in TableB? Example:
"FinishDate" in TableA updates "NextPhase" in TableB.
|
| "Steve C. Orr [MVP, MCSD]" wrote:
|
| > You could call one Stored Procedure that would in turn execute two
Update
| > statements (one for each table.)
| >
| > --
| > I hope this helps,
| > Steve C. Orr, MCSD, MVP
| > http://Steve.Orr.net
| >
| >
| > "gthompson" <gt*******@thebbpcompanies.com(donotspam)> wrote in message
| > news:07**********************************@microsof t.com...
| > > Is this possible:
| > >
| > > Read fields(rows/columns) from one sql database table (TableA). Then
| > edit/update the same 'field' in TableA; and in TableB edit/update a
| > different field - all at the same time?
| > >
| > > This is the current situation in an Access Form using Sql for the
backend.
| > We would like to convert this Access Form to a Web Form using Visual
| > Studio.net and VB.net.
| > >
| > > Please help. Thanks,
| > > gthompson
| >
| >
| >
Nov 18 '05 #5
Thanks - I'll give it a try.

"Kyril Magnos" wrote:
If using a stored procedure, sure.

CREATE PROCEDURE UpdateTables
(
@Value1 varchar(100),
@Value2 varchar(100),
@Value3 varchar(100)
)
AS
UPDATE Table1
SET Value1 = @Value2

UPDATE Table2
SET Value2 = @Value1

UPDATE Table3
SET Value3 = @Value3

GO

--
HTH

Kyril Magnos
"I'm not a developer anymore, I'm a software engineer now!" :-)

"gthompson" <gt*******@thebbpcompanies.com(donotspam)> wrote in message
news:2E**********************************@microsof t.com...
| Even if the field in TableA is not the same field as in TableB? Example:
"FinishDate" in TableA updates "NextPhase" in TableB.
|
| "Steve C. Orr [MVP, MCSD]" wrote:
|
| > You could call one Stored Procedure that would in turn execute two
Update
| > statements (one for each table.)
| >
| > --
| > I hope this helps,
| > Steve C. Orr, MCSD, MVP
| > http://Steve.Orr.net
| >
| >
| > "gthompson" <gt*******@thebbpcompanies.com(donotspam)> wrote in message
| > news:07**********************************@microsof t.com...
| > > Is this possible:
| > >
| > > Read fields(rows/columns) from one sql database table (TableA). Then
| > edit/update the same 'field' in TableA; and in TableB edit/update a
| > different field - all at the same time?
| > >
| > > This is the current situation in an Access Form using Sql for the
backend.
| > We would like to convert this Access Form to a Web Form using Visual
| > Studio.net and VB.net.
| > >
| > > Please help. Thanks,
| > > gthompson
| >
| >
| >

Nov 18 '05 #6
The current sql UPDATE is being used in an Access form:

Private Sub Finish_AfterUpdate()
Me.Complete = -1
DoCmd.RunCommand acCmdSaveRecord
Dim MinIncomplete, MaxComplete, sql
MaxComplete = DMax("[SortOrder]", "[fieldProgressSub]", "[LotCode] = '" & Forms!FieldLotProgress!LotCode & "' And [Complete] = -1")
MinIncomplete = DMin("[sortorder]", "[fieldprogresssub]", "[lotcode] = '" & Forms!FieldLotProgress!LotCode & "' And [Complete] = 0 And [SortOrder] > '" & MaxComplete & "'")
If Not IsNull(MinIncomplete) Then
Forms!FieldLotProgress!NextPhase = MinIncomplete
Else
Forms!FieldLotProgress!NextPhase = 0
End If
If Me.Type = "Insp Soil" Then
If MsgBox("Does the drive get graded with the floor on this lot " & Forms!FieldLotProgress!LotCode & "?", vbQuestion + vbYesNo, "Grade Drive") = vbYes Then
If IsNull(DLookup("[LotCode]", "FieldLotMeasurements", "[LotCode] = '" & Forms!FieldLotProgress!LotCode & "'")) Then
MsgBox "Please remember for future scheduling to input the driveway measurements before setting up grade schedule"
End If

sql = "UPDATE FieldGraderSchedule SET CalledIn = '" & Date & "' WHERE Lotcode = '" & Forms!FieldLotProgress!LotCode & "' AND Phase = 'Shade/Grade' OR Lotcode = '" & Forms!FieldLotProgress!LotCode & "' AND Phase = 'Grade Floor' OR Lotcode = '" & Forms!FieldLotProgress!LotCode & "' AND Phase = 'Grade Drive/Walk' OR Lotcode = '" & Forms!FieldLotProgress!LotCode & "' AND Phase = 'Shade Soil' "
DoCmd.RunSQL sql

sql = "UPDATE FieldGraderSchedule SET Tons = '" & (DSum("[SquareFeet]", "FieldLotMeasurements", "[LotCode] = '" & Forms!FieldLotProgress!LotCode & "'") * 0.0046) * (DLookup("[SubThickness]", "EstimatingSubdivision", "[SubdivCode] = '" & DLookup("[SubdivCode]", "EstimatingLot", "[LotCode] = '" & Forms!FieldLotProgress!LotCode & "'") & "'")) & "' WHERE Lotcode = '" & Forms!FieldLotProgress!LotCode & "' AND Phase = 'Grade Drive/Walk' "
DoCmd.RunSQL sql

Else
sql = "UPDATE FieldGraderSchedule SET CalledIn = '" & Date & "' WHERE Lotcode = '" & Forms!FieldLotProgress!LotCode & "' AND Phase = 'Shade/Grade' OR Lotcode = '" & Forms!FieldLotProgress!LotCode & "' AND Phase = 'Grade Floor' OR Lotcode = '" & Forms!FieldLotProgress!LotCode & "' AND Phase = 'Shade Soil' "
DoCmd.RunSQL sql

End If
End If
If Me.Type = "Insp PrePour" Then
DoCmd.OpenForm "FieldSuperCheckList"
End If
End Sub

Can I do something similar to this in Visual Studio.net?
"Kyril Magnos" wrote:
If using a stored procedure, sure.

CREATE PROCEDURE UpdateTables
(
@Value1 varchar(100),
@Value2 varchar(100),
@Value3 varchar(100)
)
AS
UPDATE Table1
SET Value1 = @Value2

UPDATE Table2
SET Value2 = @Value1

UPDATE Table3
SET Value3 = @Value3

GO

--
HTH

Kyril Magnos
"I'm not a developer anymore, I'm a software engineer now!" :-)

"gthompson" <gt*******@thebbpcompanies.com(donotspam)> wrote in message
news:2E**********************************@microsof t.com...
| Even if the field in TableA is not the same field as in TableB? Example:
"FinishDate" in TableA updates "NextPhase" in TableB.
|
| "Steve C. Orr [MVP, MCSD]" wrote:
|
| > You could call one Stored Procedure that would in turn execute two
Update
| > statements (one for each table.)
| >
| > --
| > I hope this helps,
| > Steve C. Orr, MCSD, MVP
| > http://Steve.Orr.net
| >
| >
| > "gthompson" <gt*******@thebbpcompanies.com(donotspam)> wrote in message
| > news:07**********************************@microsof t.com...
| > > Is this possible:
| > >
| > > Read fields(rows/columns) from one sql database table (TableA). Then
| > edit/update the same 'field' in TableA; and in TableB edit/update a
| > different field - all at the same time?
| > >
| > > This is the current situation in an Access Form using Sql for the
backend.
| > We would like to convert this Access Form to a Web Form using Visual
| > Studio.net and VB.net.
| > >
| > > Please help. Thanks,
| > > gthompson
| >
| >
| >

Nov 18 '05 #7
Yes this code should work in VB.NET will little code modification required.
You'll need to change the DoCmd lines to use ADO.NET commands instead, And
you'll need to change your form references to point to your webforms instead
(of course) but that's about it.

--
I hope this helps,
Steve C. Orr, MCSD, MVP
http://Steve.Orr.net
"gthompson" <gt*******@thebbpcompanies.com(donotspam)> wrote in message
news:72**********************************@microsof t.com...
The current sql UPDATE is being used in an Access form:

Private Sub Finish_AfterUpdate()
Me.Complete = -1
DoCmd.RunCommand acCmdSaveRecord
Dim MinIncomplete, MaxComplete, sql
MaxComplete = DMax("[SortOrder]", "[fieldProgressSub]", "[LotCode] = '" & Forms!FieldLotProgress!LotCode & "' And [Complete] = -1") MinIncomplete = DMin("[sortorder]", "[fieldprogresssub]", "[lotcode] = '" & Forms!FieldLotProgress!LotCode & "' And [Complete] = 0 And [SortOrder] >
'" & MaxComplete & "'") If Not IsNull(MinIncomplete) Then
Forms!FieldLotProgress!NextPhase = MinIncomplete
Else
Forms!FieldLotProgress!NextPhase = 0
End If
If Me.Type = "Insp Soil" Then
If MsgBox("Does the drive get graded with the floor on this lot " & Forms!FieldLotProgress!LotCode & "?", vbQuestion + vbYesNo, "Grade Drive") =
vbYes Then If IsNull(DLookup("[LotCode]", "FieldLotMeasurements", "[LotCode] = '" & Forms!FieldLotProgress!LotCode & "'")) Then MsgBox "Please remember for future scheduling to input the driveway measurements before setting up grade schedule" End If

sql = "UPDATE FieldGraderSchedule SET CalledIn = '" & Date & "' WHERE Lotcode = '" & Forms!FieldLotProgress!LotCode & "' AND Phase =
'Shade/Grade' OR Lotcode = '" & Forms!FieldLotProgress!LotCode & "' AND
Phase = 'Grade Floor' OR Lotcode = '" & Forms!FieldLotProgress!LotCode & "'
AND Phase = 'Grade Drive/Walk' OR Lotcode = '" &
Forms!FieldLotProgress!LotCode & "' AND Phase = 'Shade Soil' " DoCmd.RunSQL sql

sql = "UPDATE FieldGraderSchedule SET Tons = '" & (DSum("[SquareFeet]", "FieldLotMeasurements", "[LotCode] = '" &
Forms!FieldLotProgress!LotCode & "'") * 0.0046) * (DLookup("[SubThickness]",
"EstimatingSubdivision", "[SubdivCode] = '" & DLookup("[SubdivCode]",
"EstimatingLot", "[LotCode] = '" & Forms!FieldLotProgress!LotCode & "'") &
"'")) & "' WHERE Lotcode = '" & Forms!FieldLotProgress!LotCode & "' AND
Phase = 'Grade Drive/Walk' " DoCmd.RunSQL sql

Else
sql = "UPDATE FieldGraderSchedule SET CalledIn = '" & Date & "' WHERE Lotcode = '" & Forms!FieldLotProgress!LotCode & "' AND Phase =
'Shade/Grade' OR Lotcode = '" & Forms!FieldLotProgress!LotCode & "' AND
Phase = 'Grade Floor' OR Lotcode = '" & Forms!FieldLotProgress!LotCode & "'
AND Phase = 'Shade Soil' " DoCmd.RunSQL sql

End If
End If
If Me.Type = "Insp PrePour" Then
DoCmd.OpenForm "FieldSuperCheckList"
End If
End Sub

Can I do something similar to this in Visual Studio.net?
"Kyril Magnos" wrote:
If using a stored procedure, sure.

CREATE PROCEDURE UpdateTables
(
@Value1 varchar(100),
@Value2 varchar(100),
@Value3 varchar(100)
)
AS
UPDATE Table1
SET Value1 = @Value2

UPDATE Table2
SET Value2 = @Value1

UPDATE Table3
SET Value3 = @Value3

GO

--
HTH

Kyril Magnos
"I'm not a developer anymore, I'm a software engineer now!" :-)

"gthompson" <gt*******@thebbpcompanies.com(donotspam)> wrote in message
news:2E**********************************@microsof t.com...
| Even if the field in TableA is not the same field as in TableB? Example: "FinishDate" in TableA updates "NextPhase" in TableB.
|
| "Steve C. Orr [MVP, MCSD]" wrote:
|
| > You could call one Stored Procedure that would in turn execute two
Update
| > statements (one for each table.)
| >
| > --
| > I hope this helps,
| > Steve C. Orr, MCSD, MVP
| > http://Steve.Orr.net
| >
| >
| > "gthompson" <gt*******@thebbpcompanies.com(donotspam)> wrote in message | > news:07**********************************@microsof t.com...
| > > Is this possible:
| > >
| > > Read fields(rows/columns) from one sql database table (TableA). Then | > edit/update the same 'field' in TableA; and in TableB edit/update a
| > different field - all at the same time?
| > >
| > > This is the current situation in an Access Form using Sql for the
backend.
| > We would like to convert this Access Form to a Web Form using Visual
| > Studio.net and VB.net.
| > >
| > > Please help. Thanks,
| > > gthompson
| >
| >
| >

Nov 18 '05 #8

This thread has been closed and replies have been disabled. Please start a new discussion.

Similar topics

5
by: jayson_13 | last post by:
Hi, I need to implement a counter and i face problem of locking so hope that u guys can help me. I try to do test like this : 1st connection SELECT * FROM nextkey WHERE tblname = 'PLCN'...
8
by: Jan van Veldhuizen | last post by:
The UPDATE table FROM syntax is not supported by Oracle. I am looking for a syntax that is understood by both Oracle and SqlServer. Example: Table1: id name city ...
10
by: Hank1234 | last post by:
Can I use one Data Adapter and one Command Builder to update amny tables? Currently in my data adapter I query two tables and fill them into two tables in a data set. When I make a change to a...
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...
5
by: PAUL | last post by:
Hello, I have 2 tables with a relationship set up in the dataset with vb ..net. I add a new record to the parent table then edit an existing child record to have the new parent ID. However when I...
1
by: Grant McLean | last post by:
Hi First a simple question ... I have a table "access_log" that has foreign keys "app_id" and "app_user_id" that reference the "application_type" and "app_user" tables. When I insert into...
3
by: jpr | last post by:
Hello, I know that this is not the rule but need some help. My datbase has three tables: MASTER TEMPLATES FORMS I have a form which is based on a table named MASTER. I have a primary key...
2
by: Brett | last post by:
My database has 2 tables: Table1 & Table2. If a field is not null on a record in table2, then the not null fields in table1 that correspond to the records in table1 needs to be updated to match the...
2
by: BobLewiston | last post by:
Some of you may have seen my earlier thread “PasswordHash NULL problem”. I’ve started a new thread because investigation has shown that the problem is actually quite different than I previously...
0
by: taylorcarr | last post by:
A Canon printer is a smart device known for being advanced, efficient, and reliable. It is designed for home, office, and hybrid workspace use and can also be used for a variety of purposes. However,...
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
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: nemocccc | last post by:
hello, everyone, I want to develop a software for my android phone for daily needs, any suggestions?
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
by: Hystou | last post by:
There are some requirements for setting up RAID: 1. The motherboard and BIOS support RAID configuration. 2. The motherboard has 2 or more available SATA protocol SSD/HDD slots (including MSATA, M.2...
0
by: Hystou | last post by:
Most computers default to English, but sometimes we require a different language, especially when relocating. Forgot to request a specific language before your computer shipped? No problem! You can...
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...

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.