日期:2014-05-18  浏览次数:20535 次

怎么同时插入两个表
有3个表:caterogy(课程),字段:caterogyid,caterogyname,caterogydescription,viewcount,datetime,ohter(地址);depart(部门)表,字段:departid,departname,viewcount;category_in_depart表,字段:
departid,caterogyid,caterogyname,viewcount

现在要有管理员添加功能:
<tr> <td   style= "height:   68px "> 院系名称 </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> 课程名称 </td>
<td>
        <asp:TextBox   ID= "TextBox2 "   runat= "server "> </asp:TextBox> </td> </tr>
          <tr> <td> 课程编号 </td>
<td>
        <asp:TextBox   ID= "TextBox1 "   runat= "server "> </asp:TextBox> </td> </tr>
       
        <tr> <td> 课程描述 </td>
<td>
        <asp:TextBox   ID= "TextBox3 "   runat= "server "   Height= "62px "   Width= "168px "> </asp:TextBox> </td> </tr>
        <tr> <td> 地址 </td>
<td>
        <asp:TextBox   ID= "TextBox4 "   runat= "server "> </asp:TextBox> </td> </tr>
      <tr> <td>
              <asp:Button   ID= "Button1 "   runat= "server "   Text= "发表 "   OnClick= "Button1_Click "   /> </td>
              <td> <asp:Label   runat= "server "   ID= "result "> </asp:Label> </td> </tr>
就是说要把新的记录插到两个表中,写access的语句?


------解决方案--------------------
触发器
------解决方案--------------------
create trigger on table1
for insert
as
if inseted(table1)
begin
insert into table2 values ...
end
建好触发器后当插入table1的同时table2也插入内容