| |

VerySource

 Forgot password?
 Register
Search
View: 1308|Reply: 11

How to insert two tables at the same time

[Copy link]

1

Threads

6

Posts

4.00

Credits

Newbie

Rank: 1

Credits
4.00

 China

Post time: 2020-1-21 23:40:01
| Show all posts |Read mode
There are 3 tables: categoryrogy (course), fields: categoryrogyid, categoryrogyname, categoryrogydescription, viewcount, datetime, ohter (address); department (department) table, fields: departmentid, departmentname, viewcount; category_in_depart table, fields:
departid, caterogyid, caterogyname, viewcount

Now it's time for administrators to add functionality:
<tr> <td style = "height: 68px"> Department name </ td>
<td style = "height: 68px">
    <asp: DropDownList ID = "DropDownList1" runat = "server" DataSourceID = "AccessDataSource1"
        DataTextField = "departname" DataValueField = "departid">
    </ asp: DropDownList>
    <asp: AccessDataSource ID = "AccessDataSource1" runat = "server" DataFile = "~ / App_Data / videoplay.mdb"
        SelectCommand = "SELECT [departid], [departname] FROM [depart]"> </ asp: AccessDataSource>
</ td>
</ tr>
<tr>
<td> course name </ td>
<td>
    <asp: TextBox ID = "TextBox2" runat = "server"> </ asp: TextBox> </ td> </ tr>
     <tr> <td> Course ID </ td>
<td>
    <asp: TextBox ID = "TextBox1" runat = "server"> </ asp: TextBox> </ td> </ tr>
    
    <tr> <td> Course description </ td>
<td>
    <asp: TextBox ID = "TextBox3" runat = "server" Height = "62px" Width = "168px"> </ asp: TextBox> </ td> </ tr>
    <tr> <td> address </ td>
<td>
    <asp: TextBox ID = "TextBox4" runat = "server"> </ asp: TextBox> </ td> </ tr>
   <tr> <td>
       <asp: Button ID = "Button1" runat = "server" Text = "post" OnClick = "Button1_Click" /> </ td>
       <td> <asp: Label runat = "server" ID = "result"> </ asp: Label> </ td> </ tr>
That is to say, to insert new records into two tables and write access statements?
Reply

Use magic Report

0

Threads

114

Posts

69.00

Credits

Newbie

Rank: 1

Credits
69.00

 China

Post time: 2020-1-31 12:00:01
| Show all posts
trigger
Reply

Use magic Report

1

Threads

6

Posts

4.00

Credits

Newbie

Rank: 1

Credits
4.00

 China

 Author| Post time: 2020-1-31 14:09:01
| Show all posts
Can you tell me more about LS? Thank you
Reply

Use magic Report

0

Threads

114

Posts

69.00

Credits

Newbie

Rank: 1

Credits
69.00

 China

Post time: 2020-1-31 18:27:01
| Show all posts
create trigger on table1
for insert
as
if inseted (table1)
begin
insert into table2 values ​​...
end
After building the trigger, when table1 is inserted, table2 also inserts content
Reply

Use magic Report

0

Threads

66

Posts

27.00

Credits

Newbie

Rank: 1

Credits
27.00

 China

Post time: 2020-1-31 18:36:01
| Show all posts
Insert the main table, get @@ identity, insert the related table
Reply

Use magic Report

0

Threads

211

Posts

108.00

Credits

Newbie

Rank: 1

Credits
108.00

 China

Post time: 2020-1-31 19:00:01
| Show all posts
access without trigger
Reply

Use magic Report

0

Threads

114

Posts

69.00

Credits

Newbie

Rank: 1

Credits
69.00

 China

Post time: 2020-1-31 19:45:01
| Show all posts
--# Down, then I do n’t know ~
Reply

Use magic Report

1

Threads

6

Posts

4.00

Credits

Newbie

Rank: 1

Credits
4.00

 China

 Author| Post time: 2020-1-31 20:54:01
| Show all posts
How shouldfanfan1980be written?
PS: You helped me solve the last problem
:)
Reply

Use magic Report

1

Threads

6

Posts

4.00

Credits

Newbie

Rank: 1

Credits
4.00

 China

 Author| Post time: 2020-1-31 22:54:01
| Show all posts
That is to say, it needs to be inserted into two tables: category and department, but the third table, cate_in_depart, also needs to change accordingly, and how can the rest of the fields such as categoryid get values?
Reply

Use magic Report

0

Threads

211

Posts

108.00

Credits

Newbie

Rank: 1

Credits
108.00

 China

Post time: 2020-2-1 14:54:02
| Show all posts
Can't write two insert statements?
Reply

Use magic Report

You have to log in before you can reply Login | Register

Points Rules

Contact us|Archive|Mobile|CopyRight © 2008-2023|verysource.com ( 京ICP备17048824号-1 )

Quick Reply To Top Return to the list