在 vb.net 中使用 sql table 等 sql 参数

Use sql table like sql parameter in vb.net

我有 sql 个参数的查询。我的参数必须是我的 table 来自数据库,我现在不知道如何实现这一点。

我是这样做的:

myCommand = myConnection.CreateCommand()
myCommand.CommandType = CommandType.Text
myCommand.CommandText =
"SELECT Id, Bez, Param5, Info from Table" & "@idFixed"
myCommand.Parameters.Add("@idFixed", SqlDbType.VarChar).Value = strIdFixed

strIdFixed(传递的参数)一定是id,因为我有很多table的名字是Table01, Table02, Table333 ....

我有

Dim tableName As String = "Test" + strIdFixed.ToString.Trim
Dim builder = New SqlCommandBuilder()
Dim escapedTableName As String = builder.QuoteIdentifier(tableName)

myCommand = myConnection.CreateCommand()
myCommand.CommandType = CommandType.Text
myCommand.CommandText =
"SELECT Id, Bez, Param5, Info from " + escapedTableName

感谢