【问题标题】:Insert statement with join使用连接插入语句
【发布时间】:2020-11-19 00:55:58
【问题描述】:

我有两个表 [Departments],ID、Department_Name、[Employees] Emp_ID、Emp_Name、Dep_ID 外键是 Departments.ID

首先我select *部门名称并将其显示在Departments表的下拉列表中:

<asp:DropDownList ID="DropDownList1" runat="server" 
     DataSourceID="SqlDataSource1" DataTextField="Dep_Name" 
     DataValueField="Dep_Name">
</asp:DropDownList>

<asp:SqlDataSource ID="SqlDataSource1" runat="server" 
     ConnectionString="<%$ ConnectionStrings:Attend_DBConnectionString %>" 
     SelectCommand="SELECT [Dep_Name] FROM [Departments]">
</asp:SqlDataSource>

我想从下拉列表中选择部门名称并插入到与从Department 表中选择的Department_name 匹配的EmployeesDep_Id 列中

【问题讨论】:

    标签: asp.net sql-server


    【解决方案1】:

    查看 Microsoft 的本教程,了解如何在 ASP.Net 核心中读取相关数据。 相同的示例也可用于实体框架。谷歌康托索大学。

    https://docs.microsoft.com/en-us/aspnet/core/data/ef-rp/read-related-data?view=aspnetcore-3.1&tabs=visual-studio[enter此处链接描述]1

    【讨论】:

      猜你喜欢
      • 2018-12-28
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 2017-11-29
      • 2018-04-15
      • 1970-01-01
      相关资源
      最近更新 更多