# Re: 可以

Posted by nothing on September 02, 1999 at 14:21:08:

In Reply to: SQL叙述From后可否使用变数 posted by wu on September 02, 1999 at 13:26:10:

: 因为我要写一个类似副程式的功能,只传Table名称与栏位名称给他,即帮我Select出来,所Table名称要随这参数变动,我怎么试都试不出来,还是有期他的方式可答到同样的效果,还请各位先进指教。

Dim mdept As String
mdept = "Department" 'table 的变数
Dim DepartmentSQLBasicString As String
DepartmentSQLBasicString = "select '部门代号'=DepaNo, '部门名称'=DepaName from " & mdept
Set DepartmentRecordset = New ADODB.Recordset
With DepartmentRecordset
Set .ActiveConnection = AccountConnection
.CursorLocation = adUseClient
.CursorType = adOpenStatic
.LockType = adLockBatchOptimistic
.Open DepartmentSQLBasicString
End With

Follow Ups: