Dim cn As New OleDbConnection(My.Settings.connection)
Dim SQLResult As Object
Dim SQL As New OleDbCommand
cn.Open()
SQL.Connection = cn
SQL.CommandText = "SELECT COUNT(*) FROM (SELECT DISTINCT StudentNumber FROM StudentTable)"
SQLResult = SQL.ExecuteScalar
MsgBox(SQLResult)
cn.Close()
我想添加此WHERE节,例如'%“ + StudentNumberTextBox.Text +”%“
答案 0 :(得分:0)
我使用表格适配器
SELECT COUNT(*)
FROM (SELECT DISTINCT StudentNumber FROM PresentStudentTable
WHERE (StudentNumber = ?))
在表单代码上
TableTableAdapter.NameOfQuery(StudentNumberTextBox.Text)