gpt4 book ai didi

sql - 在 VB.NET 中使用系统表

转载 作者:行者123 更新时间:2023-12-04 20:45:35 25 4
gpt4 key购买 nike

我想在 VB.NET 应用程序中使用以下 SQL 语句:

select * from information_schema.parameters
where specific_name='GetTaskEvents'

SELECT *
FROM
INFORMATION_SCHEMA.ROUTINES
WHERE
ROUTINE_NAME= 'GetTaskEvents'

我今天和 DBA 谈了这件事,他似乎不太明白,但没有给出任何理由。这样做是不好的做法吗?

我希望能够做这样的事情
public sub Delete()
'loop around about ten databases
'Call the delete function in each of the databases (check that the stored procedure exists first)
'Each database has different output parameters. Deal with them differently e.g. if there is an email parameter, then email the person to say the record was deleted.
End Sub

这样做的原因是我可以对每个数据库都一视同仁。

最佳答案

如果您知道存储过程是什么但不确定参数是什么 - 更好的使用方法 SqlCommandBuilder.DeriveParameters方法来获取参数的数量以及它们的类型和名称。

更新 这是 VB.NET 中的基本用法示例

Dim oCommand As New SqlCommand("SpName", oConnObject)
oCommand.CommandType = CommandType.StoredProcedure
SqlCommandBuilder.DeriveParameters(oCommand)

此时 oCommand.Parameters集合将填充“SpName”的参数

关于sql - 在 VB.NET 中使用系统表,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/18705386/

25 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com