-1

我正在为一家旅游公司建立一个客户数据库系统。

他们希望能够一键检索所有客户电子邮件,并将其显示在页面上的文本框中,他们可以将其复制并粘贴到 Outlook 中。

目前,文本框称为 emailList,在单击名为 emailGet 的按钮之前是不可见的。

但是,我不知道如何使文本出现在 SQL 查询的文本框中。

我的 SQL 查询是:SELECT CEmail FROM Clients. 差不多就是这样。

在伪代码中,我想做的是:

sqlQuery = "SELECT CEmail FROM Clients"
Execute select query and store results (in a variable? or maybe directly to the textbox?)
emailList.Text = Result of sqlQuery

谢谢!:)

4

1 回答 1

1
Private Sub GetEmailAddresses() 
        Dim sText As String = String.Empty
    Dim sConnString As String = String.Empty 'Put your connection string in here

    Using cn As New OleDb.OleDbConnection(sConnString)
        cn.Open()
        Dim cmd As New OleDb.OleDbCommand("SELECT CEmail FROM Clients", cn)
        Dim r As OleDb.OleDbDataReader = cmd.ExecuteReader()

        If Not r.HasRows Then Exit Sub

        Do While r.Read()
            sText = sText & ";" & r.GetString(0)
        Loop

        cn.Close()
    End Using

    txtboxList.Text = sText
End Sub
于 2013-07-11T23:46:56.333 回答