从VB.Net代码创建商店程序 [英] Create a Store Proceedure from VB.Net Code

查看:148
本文介绍了从VB.Net代码创建商店程序的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

是否可以通过运行VB.Net代码生成存储过程,以便随后可以在以后的代码部分中调用该过程,而不是使用内联SQL?

无法保证将要连接的数据库处于我的控制之下,甚至不能由我的应用程序创建,因此我无法预加载存储的过程,一旦用户告诉我"Connect",就需要动态创建它.到该服务器,然后到该数据库".

当然,我还需要知道该过程是否失败,以便返回错误消息无法继续"

任何建议,文章或示例都会受到赞赏.

谢谢.

Is it possible to generate a stored proceedure by running VB.Net code so I can then call that proceedure in future sections of code rather than using inline SQL?

The database that I''ll be connected to isn''t guaranteed to be under my control or even created by my application so I can''t preload the stored proceedure, I need to create it dynamically once my user tells me "Connect to this Server and then this DB".

Of course I also need to know if the process fails so I can return an error saying "Unable to proceed"

Any suggestions, articles, or examples appreciated.

Thanks.

推荐答案

真的没有什么特别的.如果要创建存储过程,只需创建命令文本并调用ExecuteNonQuery,就像更新命令一样.

但是,问题可能在于运行代码的用户可能具有的权限. DBA可能(也可能不会)授予创建存储过程的权限.如果他们不控制正常添加存储的proc,那么他们肯定不希望通过代码创建任何类型的过程.
There sin''t anything special really. If you want to create a stored procedure you just create the command text and call ExecuteNonQuery, just as with say an update command.

The issue may be, however, with the permissions the user who is running the code may have. The DBA may not, and probably will not, give the permissions to create stored procs. If they won''t give control to add the stored proc normally, they certainly don''t want any type of procedure being created by code.


这篇关于从VB.Net代码创建商店程序的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆