What this Visual Basic 6.0 code do?
下面的VisualBasic6.0代码是做什么的?然而,它已经被用于搜索功能,我不清楚它。所以请解释一下它的作用。
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 | Private Sub cmdSearch_Click() Dim key As Integer, str As String key = InputBox("Enter the Employee No whose details u want to know:") Set rs = Nothing str ="select * from emp where e_no=" & key rs.Open str, adoconn, adOpenForwardOnly, adLockReadOnly txtNo.Text = rs(0) txtName.Text = rs(1) txtCity.Text = rs(2) txtDob.Text = rs(4) txtPhone.Text = rs(3) Set rs = Nothing str ="select * from emp" rs.Open str, adoconn, adOpenDynamic, adLockPessimistic End Sub |
目前还没有人明确指出,
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 | Private Sub cmdSearch_Click() Dim key As Integer, str As String key = InputBox("Enter the Employee No whose details u want to know:") ''// query the user for a name Set rs = Nothing str ="select * from emp where e_no=" & key ''//create sql query on the fly rs.Open str, adoconn, adOpenForwardOnly, adLockReadOnly ''// create a connection to an sql database txtNo.Text = rs(0) ''//assign the results of the query to input fields or labels txtName.Text = rs(1) txtCity.Text = rs(2) txtDob.Text = rs(4) txtPhone.Text = rs(3) Set rs = Nothing str ="select * from emp" rs.Open str, adoconn, adOpenDynamic, adLockPessimistic ''// creates a new sql connection and load the whole emp table End Sub |
简短摘要:要求用户输入名称,并在标签或文本框中显示用户的数据。
它基于名为
它对数据库进行两次搜索。第一次搜索的结果用于填充一些文本框。第二次搜索的结果…我不知道他们在用它做什么。