基于Dropdownlist.SelectedItem & 发送电子邮件还将 Dropdownlist.SelectedValue 插入数据库

发布于 2024-10-23 21:50:29 字数 921 浏览 1 评论 0原文

我不知道该怎么办。我有一个带有下拉列表的网络表单,名为“招聘人员”。我有两个名为 Perm_Commission_Lookup 和 Perm_Commission_Lookup 的 SQL 表。用户列表。

其中一个表包含电子邮件,而另一个则不包含。 Perm_Commission_Lookup 表不包含招聘人员的电子邮件,因此我决定将其与包含招聘人员电子邮件的 UserList 表进行内部联接。 Perm_Commission_Lookup 表中的 LookupValue(招聘人员的显示名称)列是向最终用户显示的内容,pk_LookupID 列是插入到数据库中的列。

我想要实现的是:当用户从招聘人员下拉列表中选择“John Doe”时,我想向 John Doe 发送一封电子邮件,提醒他表单已提交,同时插入所选内容值 (pk_LookupID) 存入数据库。

我看到下拉列表有两个名为: DataTextField="LookupValue"DataValueField="pk_LookupID 的字段,但如何获取 User_Email 是我的主要问题。下面是我的 SQL选择...到目前为止,我可以执行 SQL INNER JOIN...如下所示,我还可以在下拉列表中显示多列...我也在尝试 SQLDataReader 但我只是停止如何完成它任何

SELECT  Perm_Commision_Lookup.pk_LookupID, Perm_Commision_Lookup.LookupValue, UserList.User_Email 

FROM Perm_Commision_Lookup

INNER JOIN UserList ON Perm_Commision_Lookup.LookupUserName = UserList.GM_Username

帮助将不胜感激...

I don't know how to go about this. I have a web form with dropdown list, named Recruiter. I have two SQL tables named Perm_Commision_Lookup & UserList.

One of the tables contain email and the other does not. The Perm_Commision_Lookup table does not contain recruiter's email, so I decided to Inner Join it with UserList table which contain recruiter emails. The LookupValue (Recruiter's display name) column from the Perm_Commision_Lookup table is what's displayed to the end user and the pk_LookupID column is the one that's inserted into the database.

What I want to achieve is this: When a user select let's say "John Doe" from the Recruiter dropdown list, I want to send out an email to John Doe alerting him that a form has been submitted and at the same time insert the selected value (pk_LookupID) into the database.

I see that the dropdown list has two field named: DataTextField="LookupValue" and DataValueField="pk_LookupID but how to get the User_Email is my major problem. Below is my SQL select...So far I can do a SQL INNER JOIN...which shown below and also I can display multiple columns into dropdown list...I'm also trying SQLDataReader but I'm just stop with how to get it done.

SELECT  Perm_Commision_Lookup.pk_LookupID, Perm_Commision_Lookup.LookupValue, UserList.User_Email 

FROM Perm_Commision_Lookup

INNER JOIN UserList ON Perm_Commision_Lookup.LookupUserName = UserList.GM_Username

Any help will be appreciated...

如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

扫码二维码加入Web技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。

评论(2

明媚殇 2024-10-30 21:50:29

感谢您的回复!正确的!它通过 LookupUserName 链接。这就是我现在所拥有的......但仍然有问题

Public Sub BindDropDownListData()
' 连接字符串
Dim connectionString As String = ConfigurationManager.ConnectionStrings("ConnectionString").ConnectionString

    Using mySqlConnection As New SqlConnection(connectionString)
        Try
            ' open the Sql connection
            mySqlConnection.Open()

            ' Sql Command query to retrieve pk_LookupID, LookupValue, GM_Username, User_Email
            Dim mySqlCommand As New SqlCommand(" SELECT  Perm_Commision_Lookup.pk_LookupID, Perm_Commision_Lookup.LookupValue, UserList.GM_Username, UserList.User_Email FROM Perm_Commision_Lookup INNER JOIN UserList ON Perm_Commision_Lookup.LookupUserName  = UserList.GM_Username   order by LookupValue asc", mySqlConnection)

            Dim mySqlDataAdapter As New SqlDataAdapter()

            mySqlDataAdapter.SelectCommand = mySqlCommand
            Dim myDataSet As New DataSet
            ' mySqlConnection.Open()


            ' Sql Data Reader to fetch the records row by row in forward direction.
            Dim myDataReader As SqlDataReader = mySqlCommand.ExecuteReader()

            'Perm_Commision_Lookup
            If myDataReader.HasRows Then


                ' read each row fetched using DataReader
                While myDataReader.Read()
                    Dim li As New ListItem()

                    'email = myDataReader("User_Email")

                    li.Value = myDataReader("pk_LookupID")
                    li.Text = myDataReader("LookupValue")

                    DropDownList1.Items.Add(li)

                End While
            End If
            myDataReader.Close()
        Catch ex As Exception
            Label1.Text = ex.Message
        Finally
            ' close the Sql Connection
            mySqlConnection.Close()
        End Try

        DropDownList1.Items.Insert(0, New ListItem("Please Select Recruiter", ""))
    End Using
End Sub

Thanks for your reply! Correct! It's linked via LookupUserName. That's what I have as for now...but still have the problem

Public Sub BindDropDownListData()
' connection string
Dim connectionString As String = ConfigurationManager.ConnectionStrings("ConnectionString").ConnectionString

    Using mySqlConnection As New SqlConnection(connectionString)
        Try
            ' open the Sql connection
            mySqlConnection.Open()

            ' Sql Command query to retrieve pk_LookupID, LookupValue, GM_Username, User_Email
            Dim mySqlCommand As New SqlCommand(" SELECT  Perm_Commision_Lookup.pk_LookupID, Perm_Commision_Lookup.LookupValue, UserList.GM_Username, UserList.User_Email FROM Perm_Commision_Lookup INNER JOIN UserList ON Perm_Commision_Lookup.LookupUserName  = UserList.GM_Username   order by LookupValue asc", mySqlConnection)

            Dim mySqlDataAdapter As New SqlDataAdapter()

            mySqlDataAdapter.SelectCommand = mySqlCommand
            Dim myDataSet As New DataSet
            ' mySqlConnection.Open()


            ' Sql Data Reader to fetch the records row by row in forward direction.
            Dim myDataReader As SqlDataReader = mySqlCommand.ExecuteReader()

            'Perm_Commision_Lookup
            If myDataReader.HasRows Then


                ' read each row fetched using DataReader
                While myDataReader.Read()
                    Dim li As New ListItem()

                    'email = myDataReader("User_Email")

                    li.Value = myDataReader("pk_LookupID")
                    li.Text = myDataReader("LookupValue")

                    DropDownList1.Items.Add(li)

                End While
            End If
            myDataReader.Close()
        Catch ex As Exception
            Label1.Text = ex.Message
        Finally
            ' close the Sql Connection
            mySqlConnection.Close()
        End Try

        DropDownList1.Items.Insert(0, New ListItem("Please Select Recruiter", ""))
    End Using
End Sub
远昼 2024-10-30 21:50:29

1:使用下拉selectedIndexChanged事件。

2:在处理程序内部查询数据库以获取电子邮件并发送电子邮件。

3:您可以从 SelectedIndexChanged 处理程序的下拉列表中选择查找名称(如 myddl.SelectedItem.Text),也可以获取查找 ID(如 myddl.SelectedValue)。

从您的查询来看,您的表似乎是通过 LookupUserName 正确链接的,还是 LookupId 链接的?

这可能会有所帮助。

1: Use dropdown selectedIndexChanged event.

2: Inside the handler query the database to get the Email and send email.

3: You can selected lookupname from dropdown in the SelectedIndexChanged handler like myddl.SelectedItem.Text or you can get lookupid like myddl.SelectedValue.

From your query it seems your tables are linked via LookupUserName correct or is it LookupId?

And this might help.

~没有更多了~
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文